Laravel Eloquent Where Like Query Example Tutorial
Hi Guys,
Are you looking for an example of laravel eloquent where like query. If you have a question about laravel eloquent like query then I will give a simple example with a solution. you will learn laravel where like query . I explained simply about laravel like query example. Follow the below tutorial step of laravel where like query variable.
You can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 versions.
Here, i will give you simple two example for sql like query in laravel. so let's see the simple sql query and Laravel Where with Like query.
SQL Example:
SELECT *
FROM `users`
WHERE `name` LIKE '%hard%';
Laravel Where Like Query Example 1:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
class UserController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index()
{
$search = 'hard';
$users = User::select("*")
->where('name','LIKE',"%{$search}%")
->get();
dd($users);
}
}
Laravel Where Like Query Example 2:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
class UserController extends Controller
{
/**
* Write code on Method
*
* @return response()
*/
public function index()
{
$search = 'hard';
$users = User::select("*")
->where('name','LIKE','%'.$search.'%')
->get();
dd($users);
}
}
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Eloquent whereRelation() Condition Example
- Laravel Eloquent whereHas() Condition Example
- Laravel Eloquent Left Join Where Null Condition Example
- Laravel Eloquent whereNotNull() Query Example
- Laravel Eloquent whereNotBetween() Query Example
- Laravel Eloquent whereBetween() Query Example
- Laravel Relationship Where Condition Example
- Laravel - whereDate(), whereMonth(), whereDay() and whereYear() Example
- Laravel Where Condition with Two Columns Example
- Laravel Where Clause with date_format() Example
- Laravel Eloquent Where Like Query Example Tutorial
- Laravel Where Clause with MySQL Function Example
- Laravel Query Builder Where Exists Example