| xqd
@@ -125,12 +125,15 @@ class ProductController extends Controller
|
|
|
if(empty($params)){
|
|
|
return $this->error("数据不能为空!");
|
|
|
}
|
|
|
+ if(empty($params['type'])){
|
|
|
+ return $this->error("分类不能能为空!");
|
|
|
+ }
|
|
|
$params['user_id'] = $this->userId; // 用户ID
|
|
|
$res = Product::query()->create($params);
|
|
|
if(!$res){
|
|
|
return $this->error("上传失败!");
|
|
|
}
|
|
|
- return $this->success();
|
|
|
+ return $this->success($res);
|
|
|
|
|
|
}
|
|
|
|
| xqd
@@ -156,11 +159,13 @@ class ProductController extends Controller
|
|
|
public function productList(Request $request){
|
|
|
$limit = $request->get('limit',10);
|
|
|
$type = $request->get('type');
|
|
|
- $query = Product::query()->with('user:id,name,nickname,avatar,company_name,company_card_color,production_project');
|
|
|
+ $query = Product::query()
|
|
|
+ ->with('user:id,name,nickname,avatar,company_name,company_card_color,production_project');
|
|
|
if(!empty($type)){
|
|
|
- $query->whereIn('type',$type);
|
|
|
+ $query->whereJsonContains('type',$type);
|
|
|
}
|
|
|
- $list = $query->where('status',1)->paginate($limit);
|
|
|
+ $list = $query->where('status',1)
|
|
|
+ ->paginate($limit);
|
|
|
return $this->success($this->page($list));
|
|
|
}
|
|
|
|