|
@@ -97,17 +97,31 @@ class BloggerController extends BaseController
|
|
//按类型搜
|
|
//按类型搜
|
|
$type_id = $request->type_id ?? 0;
|
|
$type_id = $request->type_id ?? 0;
|
|
|
|
|
|
|
|
+ //搜索
|
|
|
|
+ $keyword = _empty_default_($request->keyword,'');
|
|
|
|
+ if($keyword){
|
|
|
|
+ $where[] = ['ask_order.question','like','%'.$keyword.'%'];
|
|
|
|
+ }
|
|
|
|
+
|
|
//
|
|
//
|
|
$list = DB::table('blogger')
|
|
$list = DB::table('blogger')
|
|
->leftJoin('wx_user','wx_user.id','=','blogger.user_id')
|
|
->leftJoin('wx_user','wx_user.id','=','blogger.user_id')
|
|
->select('blogger.*','wx_user.user_avatar','wx_user.user_name')
|
|
->select('blogger.*','wx_user.user_avatar','wx_user.user_name')
|
|
- ->where('blogger.status',1);
|
|
|
|
|
|
+ ->where('blogger.status',1)
|
|
|
|
+ ->inRandomOrder()->offset($offset)->limit($limit);
|
|
|
|
|
|
if($type_id){
|
|
if($type_id){
|
|
$list = $list->whereRaw('FIND_IN_SET(?,type_ids)',[$type_id]);
|
|
$list = $list->whereRaw('FIND_IN_SET(?,type_ids)',[$type_id]);
|
|
}
|
|
}
|
|
|
|
|
|
- $list = $list->inRandomOrder()->offset($offset)->limit($limit)->get();
|
|
|
|
|
|
+ if($keyword){
|
|
|
|
+ $list = $list->where(function($query) use ($keyword) {
|
|
|
|
+ $query->orWhere('wx_user.user_name','like','%'.$keyword.'%')
|
|
|
|
+ ->orWhere('blogger.info' ,'like','%'.$keyword.'%');
|
|
|
|
+ })->reorder('blogger.user_id','desc');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $list = $list->get();
|
|
|
|
|
|
return $this->success($list);
|
|
return $this->success($list);
|
|
}
|
|
}
|