“Query Builder use Like Query with WHERE Condition in Laravel,Like Query use in Laravel 5.8,Eloquent Like Query Use Laravel,Like Query use in Laravel 5.7,Like Query use in Laravel 5.6”
In the laravel framework, the use of like query is used to filter the match value of the select column of the table.In the laravel framework, the like query is used in where condition.
Example: Suppose the name of some users in your table’s username (Jack, Mac, Rocky) and you want to filter the same values as the rocky name. So you can filter by like query.
Query Builder use Like Query with WHERE Condition.
$filter = DB::table('users')->where('name','LIKE','%'.$variable.'%')->get();
Like Query use with Model in WHERE Condition.
$filter = User::where('name','LIKE','%'.$variable.'%')->get();
As an example, you can see below how the value of variable is used in query like.
$username = "rocky"; $filter = DB::table('users')->where('username','LIKE','%'.$username.'%')->get();