Do partial search, like %op%. Etc.
Nov 8, 2021
8
Level 1
Advanced Search Query with Eloquent
I have a mobile phone specs website. I'm using the following query it returns results correctly:
$q = 'oppo reno';
Phone::where('name', 'like', sprintf('%%%s%%', $q))->get();
However, if we change the position of words of the search query to the following, it won't return any results.
$q = 'reno oppo';
Phone::where('name', 'like', sprintf('%%%s%%', $q))->get();
Any help is appreciated, thanks!
Please or to participate in this conversation.