Home Laravel Laravel Like Query Example using Eloquent Where Clause

Laravel Like Query Example using Eloquent Where Clause

by Shahriar Sagor

Today now in this post i will show you an example of using where clause in laravel Eloquent. Whenever we need to use the select like query in our application then we can easily use this. But on Laravel provide us the query builder and mysql as like condition is very simple to use.

So let’s see the bellow example did convert the bellow sql query.

SQL Example:
SELECT *
FROM `users`
WHERE `name` LIKE '%hdtopi%';
Laravel Query Example:
$search = 'hdtopi';
$user = User::where('name','LIKE',"%{$search}%")
              ->get();
print_r($user);

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like