34 changed files with 1623 additions and 571 deletions
-
6app/Common/Helper.php
-
76app/Http/Controllers/Api/CollectGoodsController.php
-
114app/Http/Controllers/Api/CommentController.php
-
53app/Http/Controllers/Api/FeedBackController.php
-
92app/Http/Controllers/Api/IndexController.php
-
25app/Http/Controllers/Api/QrcodeController.php
-
442app/Http/Controllers/Api/UserController.php
-
9app/Http/Controllers/Api/UserMoneyController.php
-
9app/Http/Controllers/Api/UserPointController.php
-
43app/Http/Controllers/Api/VerifyCodeController.php
-
32app/Http/Controllers/Auth/ForgotPasswordController.php
-
39app/Http/Controllers/Auth/LoginController.php
-
71app/Http/Controllers/Auth/RegisterController.php
-
39app/Http/Controllers/Auth/ResetPasswordController.php
-
3app/Http/Controllers/Home/IndexController.php
-
2app/Http/Model/BaseModel.php
-
89app/Http/Model/CollectGoods.php
-
94app/Http/Model/Comment.php
-
80app/Http/Model/FeedBack.php
-
10app/Http/Model/Goods.php
-
13app/Http/Model/GoodsPhoto.php
-
10app/Http/Model/GoodsType.php
-
13app/Http/Model/ProductPic.php
-
67app/Http/Model/Sysconfig.php
-
76app/Http/Model/User.php
-
4app/Http/Model/UserAddress.php
-
12app/Http/Model/UserMoney.php
-
12app/Http/Model/UserPoint.php
-
1app/Http/Model/VerifyCode.php
-
1composer.json
-
621composer.lock
-
6config/app.php
-
25routes/web.php
-
5说明.txt
@ -0,0 +1,76 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
use App\Http\Model\CollectGoods; |
|||
|
|||
class CollectGoodsController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function collectGoodsList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['limit'] = $request->input('limit', 10); |
|||
$data['offset'] = $request->input('offset', 0); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
$res = CollectGoods::getList($data); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//收藏商品
|
|||
public function collectGoodsAdd(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['goods_id'] = $request->input('goods_id',null); |
|||
if($request->input('is_attention', null) !== null){$data['is_attention'] = $request->input('is_attention');} |
|||
$data['add_time'] = time(); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['goods_id']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = CollectGoods::add($data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//取消收藏商品
|
|||
public function collectGoodsDelete(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['goods_id'] = $request->input('goods_id',null); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['goods_id']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = CollectGoods::remove($data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,114 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
use App\Http\Model\Comment; |
|||
|
|||
class CommentController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function goodsCommentList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['limit'] = $request->input('limit', 10); |
|||
$data['offset'] = $request->input('offset', 0); |
|||
$data['user_id'] = Token::$uid; |
|||
$data['comment_type'] = $request->input('comment_type', 0); //0商品评价,1文章评价
|
|||
if($request->input('comment_rank', null) !== null){$data['comment_rank'] = $request->input('comment_rank');} |
|||
|
|||
$res = Comment::getList($data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//添加评价
|
|||
public function goodsCommentAdd(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['comment_type'] = $request->input('comment_type',0); |
|||
$data['id_value'] = $request->input('id_value',null); |
|||
$data['content'] = $request->input('content',null); |
|||
$data['comment_rank'] = $request->input('comment_rank',null); |
|||
if($request->input('email', null) !== null){$data['email'] = $request->input('email');} |
|||
if($request->input('user_name', null) !== null){$data['user_name'] = $request->input('user_name');} |
|||
if($request->input('ip_address', null) !== null){$data['ip_address'] = $request->input('ip_address');} |
|||
if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} |
|||
$data['add_time'] = time(); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = Comment::add($data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
public function goodsCommentUpdate(Request $request) |
|||
{ |
|||
//参数
|
|||
$id = $request->input('id',null); |
|||
$data['comment_type'] = $request->input('comment_type',0); |
|||
$data['id_value'] = $request->input('id_value',null); |
|||
$data['content'] = $request->input('content',null); |
|||
$data['comment_rank'] = $request->input('comment_rank',null); |
|||
if($request->input('email', null) !== null){$data['email'] = $request->input('email');} |
|||
if($request->input('user_name', null) !== null){$data['user_name'] = $request->input('user_name');} |
|||
if($request->input('ip_address', null) !== null){$data['ip_address'] = $request->input('ip_address');} |
|||
if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');} |
|||
$data['add_time'] = time(); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($id===null || $data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = Comment::modify(array('id'=>$id),$data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//删除评价
|
|||
public function goodsCommentDelete(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['comment_type'] = $request->input('comment_type',null); |
|||
$data['id_value'] = $request->input('id_value',null); |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['comment_type']===null || $data['id_value']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = Comment::remove($data); |
|||
if($res !== true) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,53 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Token; |
|||
use App\Http\Model\FeedBack; |
|||
|
|||
class FeedBackController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function feedbackList(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['limit'] = $request->input('limit', 10); |
|||
$data['offset'] = $request->input('offset', 0); |
|||
|
|||
$res = FeedBack::getList($data); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
|
|||
//添加意见反馈
|
|||
public function feedbackAdd(Request $request) |
|||
{ |
|||
//参数
|
|||
$data['content'] = $request->input('content',null); |
|||
if($request->input('title', null) !== null){$data['title'] = $request->input('title');} |
|||
$data['user_id'] = Token::$uid; |
|||
|
|||
if($data['content']===null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
$res = FeedBack::add($data); |
|||
if(!$res) |
|||
{ |
|||
return ReturnData::create(ReturnData::SYSTEM_FAIL); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS,$res); |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Helper; |
|||
|
|||
//二维码
|
|||
class QrcodeController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
public function createSimpleQrcode(Request $request) |
|||
{ |
|||
//参数
|
|||
$url = $request->input('url'); |
|||
$size = $request->input('size', 150); |
|||
|
|||
return '<img src="'.Helper::qrcode($url,$size).'">'; |
|||
} |
|||
} |
@ -0,0 +1,43 @@ |
|||
<?php |
|||
namespace App\Http\Controllers\Api; |
|||
|
|||
use App\Http\Controllers\Api\CommonController; |
|||
use Illuminate\Http\Request; |
|||
use App\Common\ReturnData; |
|||
use App\Common\Helper; |
|||
|
|||
use App\Http\Model\VerifyCode; |
|||
|
|||
class VerifyCodeController extends CommonController |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
//验证码校验
|
|||
public function check(Request $request) |
|||
{ |
|||
$mobile = $request->input('mobile', null); //手机号码
|
|||
$verifyCode = $request->input('verifyCode', null); //手机验证码
|
|||
$type = $request->input('type', null); //验证码类型
|
|||
|
|||
if ($mobile==null || $verifyCode==null || $type==null) |
|||
{ |
|||
return ReturnData::create(ReturnData::PARAMS_ERROR); |
|||
} |
|||
|
|||
if (!Helper::isValidMobile($mobile)) |
|||
{ |
|||
return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL); |
|||
} |
|||
|
|||
$verifyCode = VerifyCode::isVerify($mobile, $verifyCode, $type); |
|||
if(!$verifyCode) |
|||
{ |
|||
return ReturnData::create(ReturnData::INVALID_VERIFYCODE); |
|||
} |
|||
|
|||
return ReturnData::create(ReturnData::SUCCESS); |
|||
} |
|||
} |
@ -1,32 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Auth; |
|||
|
|||
use App\Http\Controllers\Controller; |
|||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; |
|||
|
|||
class ForgotPasswordController extends Controller |
|||
{ |
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Password Reset Controller |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| This controller is responsible for handling password reset emails and |
|||
| includes a trait which assists in sending these notifications from |
|||
| your application to your users. Feel free to explore this trait. |
|||
| |
|||
*/ |
|||
|
|||
use SendsPasswordResetEmails; |
|||
|
|||
/** |
|||
* Create a new controller instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
$this->middleware('guest'); |
|||
} |
|||
} |
@ -1,39 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Auth; |
|||
|
|||
use App\Http\Controllers\Controller; |
|||
use Illuminate\Foundation\Auth\AuthenticatesUsers; |
|||
|
|||
class LoginController extends Controller |
|||
{ |
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Login Controller |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| This controller handles authenticating users for the application and |
|||
| redirecting them to your home screen. The controller uses a trait |
|||
| to conveniently provide its functionality to your applications. |
|||
| |
|||
*/ |
|||
|
|||
use AuthenticatesUsers; |
|||
|
|||
/** |
|||
* Where to redirect users after login. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $redirectTo = '/home'; |
|||
|
|||
/** |
|||
* Create a new controller instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
$this->middleware('guest')->except('logout'); |
|||
} |
|||
} |
@ -1,71 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Auth; |
|||
|
|||
use App\User; |
|||
use App\Http\Controllers\Controller; |
|||
use Illuminate\Support\Facades\Validator; |
|||
use Illuminate\Foundation\Auth\RegistersUsers; |
|||
|
|||
class RegisterController extends Controller |
|||
{ |
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Register Controller |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| This controller handles the registration of new users as well as their |
|||
| validation and creation. By default this controller uses a trait to |
|||
| provide this functionality without requiring any additional code. |
|||
| |
|||
*/ |
|||
|
|||
use RegistersUsers; |
|||
|
|||
/** |
|||
* Where to redirect users after registration. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $redirectTo = '/home'; |
|||
|
|||
/** |
|||
* Create a new controller instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
$this->middleware('guest'); |
|||
} |
|||
|
|||
/** |
|||
* Get a validator for an incoming registration request. |
|||
* |
|||
* @param array $data |
|||
* @return \Illuminate\Contracts\Validation\Validator |
|||
*/ |
|||
protected function validator(array $data) |
|||
{ |
|||
return Validator::make($data, [ |
|||
'name' => 'required|string|max:255', |
|||
'email' => 'required|string|email|max:255|unique:users', |
|||
'password' => 'required|string|min:6|confirmed', |
|||
]); |
|||
} |
|||
|
|||
/** |
|||
* Create a new user instance after a valid registration. |
|||
* |
|||
* @param array $data |
|||
* @return User |
|||
*/ |
|||
protected function create(array $data) |
|||
{ |
|||
return User::create([ |
|||
'name' => $data['name'], |
|||
'email' => $data['email'], |
|||
'password' => bcrypt($data['password']), |
|||
]); |
|||
} |
|||
} |
@ -1,39 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Auth; |
|||
|
|||
use App\Http\Controllers\Controller; |
|||
use Illuminate\Foundation\Auth\ResetsPasswords; |
|||
|
|||
class ResetPasswordController extends Controller |
|||
{ |
|||
/* |
|||
|-------------------------------------------------------------------------- |
|||
| Password Reset Controller |
|||
|-------------------------------------------------------------------------- |
|||
| |
|||
| This controller is responsible for handling password reset requests |
|||
| and uses a simple trait to include this behavior. You're free to |
|||
| explore this trait and override any methods you wish to tweak. |
|||
| |
|||
*/ |
|||
|
|||
use ResetsPasswords; |
|||
|
|||
/** |
|||
* Where to redirect users after resetting their password. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $redirectTo = '/home'; |
|||
|
|||
/** |
|||
* Create a new controller instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
$this->middleware('guest'); |
|||
} |
|||
} |
@ -0,0 +1,89 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use App\Common\Token; |
|||
|
|||
class CollectGoods extends BaseModel |
|||
{ |
|||
//商品收藏
|
|||
|
|||
protected $table = 'collect_goods'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = []; |
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$where['user_id'] = Token::$uid; |
|||
$limit = isset($limit) ? $limit : 10; |
|||
$offset = isset($offset) ? $offset : 0; |
|||
|
|||
$model = new CollectGoods; |
|||
|
|||
if(isset($type)){$where['type'] = $type;} |
|||
|
|||
$model = $model->where($where); |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($id) |
|||
{ |
|||
return self::where('id', $id)->first()->toArray(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if(self::where(array('user_id'=>$data['user_id'],'goods_id'=>$data['goods_id']))->first()){return '亲,您已经收藏啦!';} |
|||
|
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove(array $data) |
|||
{ |
|||
if(!self::where(array('user_id'=>$data['user_id'],'goods_id'=>$data['goods_id']))->first()){return '商品未收藏';} |
|||
|
|||
if (!self::where(array('user_id'=>$data['user_id'],'goods_id'=>$data['goods_id']))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use App\Common\Token; |
|||
|
|||
class Comment extends BaseModel |
|||
{ |
|||
//评价
|
|||
|
|||
protected $table = 'comment'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = []; |
|||
|
|||
const SHOW_COMMENT = 1; //评论已审核
|
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$where['user_id'] = Token::$uid; |
|||
$where['comment_type'] = $comment_type; //0商品评价,1文章评价
|
|||
$where['status'] = self::SHOW_COMMENT; |
|||
|
|||
$limit = isset($limit) ? $limit : 10; |
|||
$offset = isset($offset) ? $offset : 0; |
|||
|
|||
$model = new Comment; |
|||
|
|||
if(isset($comment_rank)){$where['comment_rank'] = $comment_rank;} //评价分
|
|||
|
|||
$model = $model->where($where); |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); |
|||
} |
|||
else |
|||
{ |
|||
return '暂无记录'; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($id) |
|||
{ |
|||
return self::where('id', $id)->first()->toArray(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if(self::where(array('user_id'=>$data['user_id'],'id_value'=>$data['id_value'],'comment_type'=>$data['comment_type']))->first()){return '亲,您已经评价啦!';} |
|||
|
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove(array $data) |
|||
{ |
|||
if(!self::where(array('user_id'=>$data['user_id'],'comment_type'=>$data['comment_type'],'id_value'=>$data['id_value']))->first()){return '商品尚未评价';} |
|||
|
|||
if (!self::where(array('user_id'=>$data['user_id'],'comment_type'=>$data['comment_type'],'id_value'=>$data['id_value']))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,80 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use App\Common\Token; |
|||
|
|||
class FeedBack extends BaseModel |
|||
{ |
|||
//用户余额明细
|
|||
|
|||
protected $table = 'feedback'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = []; |
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$limit = isset($limit) ? $limit : 10; |
|||
$offset = isset($offset) ? $offset : 0; |
|||
|
|||
$model = new FeedBack; |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->select('title','created_at')->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($id) |
|||
{ |
|||
return self::where('id', $id)->first()->toArray(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return $id; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove($id) |
|||
{ |
|||
if (!self::whereIn('id', explode(',', $id))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use App\Common\Token; |
|||
|
|||
class GoodsPhoto extends BaseModel |
|||
{ |
|||
//产品图片
|
|||
|
|||
protected $table = 'goods_photo'; |
|||
public $timestamps = false; |
|||
|
|||
} |
@ -1,13 +0,0 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class ProductPic extends Model |
|||
{ |
|||
//产品图片
|
|||
|
|||
protected $table = 'product_pic'; |
|||
public $timestamps = false; |
|||
|
|||
} |
621
composer.lock
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Reference in new issue
xxxxxxxxxx