'fuzzy' search update

This commit is contained in:
j3d1 2019-12-26 20:21:40 +01:00
parent 4505c43bdd
commit 906201313e

View file

@ -29,12 +29,14 @@ class ItemController extends Controller
public function searchByEvent($event, $query) public function searchByEvent($event, $query)
{ {
$eid = Event::where('slug','=',$event)->first()->eid; $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') ->join('containers','items.cid','=','containers.cid')
->leftJoin('files','items.iid','=','files.iid') ->leftJoin('files','items.iid','=','files.iid')
->select('items.*','files.hash as file', 'containers.name as box') ->select('items.*','files.hash as file', 'containers.name as box');
->where('items.description', 'like' , '%'.base64_decode ( $query , true).'%') foreach ($query_tokens as $token)
->get()); $g = $q->where('items.description','like','%'.$token.'%');
return response()->json($q->get());
} }
public function showOneItem($event, $id) public function showOneItem($event, $id)