Answer the question
In order to leave comments, you need to log in
Laravel 5 Models. Is it right to simplify the query?
It is necessary to search in all fields. I do this
$ResultSearch = ListAirport::where(function ($q) use ($search_value) {
$q->where('name_one', 'like', "%{$search_value}%")
->orWhere('sity ', 'like', "%{$search_value}%")
->orWhere('name_en', 'like', "%{$search_value}%")
->orWhere('code', 'like', "% {$search_value}%")
->orWhere('key', 'like', "%{$search_value}%")
->orWhere('airport_name', 'like', "%{$search_value}%");
})->get();
return response()->json($ResultSearch);
Answer the question
In order to leave comments, you need to log in
Everything is fine here, you just need to escape the request$search_value = addcslashes($search_value, '%_');
I advise you to use Eloquence Searchable for searching
https://github.com/jarektkaczyk/eloquence/wiki/Bui...
It is possible to use relevant fulltext search, you can search by links, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question