diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index a9c9983..b736b3f 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -29,12 +29,14 @@ class ItemController extends Controller public function searchByEvent($event, $query) { $eid = Event::where('slug','=',$event)->first()->eid; - return response()->json(Item::where('eid','=',$eid) + $query_tokens = explode(" ",base64_decode ( $query , true)); + $q = Item::where('eid','=',$eid) ->join('containers','items.cid','=','containers.cid') ->leftJoin('files','items.iid','=','files.iid') - ->select('items.*','files.hash as file', 'containers.name as box') - ->where('items.description', 'like' , '%'.base64_decode ( $query , true).'%') - ->get()); + ->select('items.*','files.hash as file', 'containers.name as box'); + foreach ($query_tokens as $token) + $g = $q->where('items.description','like','%'.$token.'%'); + return response()->json($q->get()); } public function showOneItem($event, $id)