| xqd
@@ -212,11 +212,16 @@ class ProductController extends Controller
|
|
|
$query->orWhereJsonContains('type',[intval($v)]);
|
|
|
}
|
|
|
}
|
|
|
+ $query->whereHas('user',function ($q){
|
|
|
+ $q->where('is_stop',0);
|
|
|
+ });
|
|
|
if(!empty($keyword)){
|
|
|
$query->where('name','like','%'.$keyword.'%');
|
|
|
}
|
|
|
$list = $query->where('status',1)
|
|
|
->orderByDesc("id")
|
|
|
+// ->toSql();
|
|
|
+// echo $list;
|
|
|
->paginate(intval($limit));
|
|
|
foreach ($list as $v){
|
|
|
$v['is_collect'] = 0;
|
| xqd
@@ -237,6 +242,9 @@ class ProductController extends Controller
|
|
|
->with('user:id,name,nickname,avatar,company_name,company_url,production_project')
|
|
|
->where('status',1)
|
|
|
->where('id',$request->get('id'))
|
|
|
+ ->whereHas('user',function ($q){
|
|
|
+ $q->where('is_stop',0);
|
|
|
+ })
|
|
|
->select("id","name","user_id","content","image","type","url")->first();
|
|
|
if(!$data){
|
|
|
return $this->error("数据不存在!");
|
| xqd
@@ -252,10 +260,47 @@ class ProductController extends Controller
|
|
|
if(!empty($data['user'])){
|
|
|
$data['user']['follow_count'] = UserFollow::query()->where('user_id',$data['user_id'])->count();
|
|
|
}
|
|
|
- return $this->success($data);
|
|
|
+ return $this->success($data);
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取推荐信息
|
|
|
+ *
|
|
|
+ * @param Request $request
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
+ */
|
|
|
+ public function getProductRecommend(Request $request){
|
|
|
+ $type = Product::where('id',$request->get('id'))->where('status',1)->value('type');
|
|
|
+ $recommend = Product::with('user:id,name,nickname,avatar,company_name,company_url,production_project');
|
|
|
+ foreach ($type ?? [] as $v){
|
|
|
+ $recommend->orWhereJsonContains('type',[intval($v)]);
|
|
|
+ }
|
|
|
+ $recommend->where('status',1)
|
|
|
+ ->select("id","name","user_id","content","image","type","url")
|
|
|
+ ->where('id','<>',$request->get('id'))
|
|
|
+ ->whereHas('user',function ($q){
|
|
|
+ $q->where('is_stop',0);
|
|
|
+ });
|
|
|
+ $data = $recommend->orderBy('id','desc')->paginate()->toArray();
|
|
|
+ foreach ($data['data'] ?? [] as $key => $value){
|
|
|
+ if ($value['id'] == $request->get('id')){
|
|
|
+ unset($data['data'][$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data['data'] = array_values($data['data']);
|
|
|
+ if (empty($data['data'])){
|
|
|
+ $data = Product::with('user:id,name,nickname,avatar,company_name,company_url,production_project')
|
|
|
+ ->where('status',1)
|
|
|
+ ->where('id','<>',$request->get('id'))
|
|
|
+ ->select("id","name","user_id","content","image","type","url")
|
|
|
+ ->whereHas('user',function ($q){
|
|
|
+ $q->where('is_stop',0);
|
|
|
+ })
|
|
|
+ ->orderByRaw('rand()')->paginate();
|
|
|
+ }
|
|
|
+ return $this->success($data);
|
|
|
+ }
|
|
|
/**
|
|
|
* @param Request $request
|
|
|
* @return void
|
| xqd
@@ -392,6 +437,9 @@ class ProductController extends Controller
|
|
|
->with('product:id,name,image,url')
|
|
|
->whereHas('product',function ($query){
|
|
|
$query->where('id','>',0);
|
|
|
+ $query->whereHas('user',function ($q){
|
|
|
+ $q->where('is_stop',0);
|
|
|
+ });
|
|
|
})
|
|
|
->where('user_id',$user_id)
|
|
|
->where('is_arrange','=',0)
|