Skip to content

Commit

Permalink
Merge branch 'patch-32' of https://github.com/incasedo/dsshop into in…
Browse files Browse the repository at this point in the history
…casedo-patch-29
  • Loading branch information
dspurl committed Dec 5, 2020
2 parents 88bfcf5 + 08548bd commit 172b637
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/app/Http/Controllers/v1/Admin/GoodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ public function index(Request $request)
}
$q->where('is_delete',Good::GOOD_DELETE_NO);
if($request->title){
/*
MySQL<5.7并且商品不多时可用模糊搜索方式
$q->where(function($q1) use($request){
$q1->where('name','like','%'.$request->title.'%')
->orWhere('number',$request->title);
});
*/
$q->where(function($q1) use($request){
$q1->orWhereRaw('MATCH (name,keywords) AGAINST (\''.$request->title.'\' IN NATURAL LANGUAGE MODE)')
->orWhere('number',$request->title);
});

}
$q->orderBy('created_at','DESC');
$paginate=$q->with(['resources'=>function($q){
Expand Down

0 comments on commit 172b637

Please sign in to comment.