|
@@ -144,12 +144,14 @@ class ProductController extends Controller
|
|
*/
|
|
*/
|
|
public function addProduct(Request $request){
|
|
public function addProduct(Request $request){
|
|
$params = $request->all();
|
|
$params = $request->all();
|
|
- if(empty($params)){
|
|
|
|
- return $this->error("数据不能为空!");
|
|
|
|
- }
|
|
|
|
if(empty($params['type'])){
|
|
if(empty($params['type'])){
|
|
return $this->error("分类不能能为空!");
|
|
return $this->error("分类不能能为空!");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if(empty($params['url']) && empty($params['name']) && empty($params['content'])){
|
|
|
|
+ return $this->error("数据不能为空!");
|
|
|
|
+ }
|
|
|
|
+
|
|
$params['user_id'] = $this->userId; // 用户ID
|
|
$params['user_id'] = $this->userId; // 用户ID
|
|
$res = Product::query()->create($params);
|
|
$res = Product::query()->create($params);
|
|
if(!$res){
|
|
if(!$res){
|
|
@@ -346,7 +348,7 @@ class ProductController extends Controller
|
|
if($collect){
|
|
if($collect){
|
|
return $this->error("您已点赞过了!");
|
|
return $this->error("您已点赞过了!");
|
|
}
|
|
}
|
|
- $data =[
|
|
|
|
|
|
+ $data = [
|
|
'product_id' => $product->id,
|
|
'product_id' => $product->id,
|
|
'user_id' => $this->userId,
|
|
'user_id' => $this->userId,
|
|
];
|
|
];
|