Laravel Like Query Example using Eloquent Where Clause

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

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.

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →