Laravel 7/6 Where Like Query Example

10-Apr-2023

.

Admin

Hii Guys,

In this example,I will learn you how to use where like query in laravel 7/6.you can simply and easy to define where like query in laravel 7/6.

Laravel 7/6 provide query builder and mysql like condition is very simple to use.bellow example

Example 1 :-


/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$search = "raj";

$users = User::where('name', 'LIKE', "%$search%")

->latest()

->get();

dd($users);

}

Example 2 :-

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$search = "raj";

$users = User::where('name', 'LIKE', "%{$search}%")

->latest()

->get();

dd($users);

}

Example 3 :-

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$search = "raj";

$users = User::where('name', 'LIKE','%' . $search . '%')

->latest()

->get();

dd($users);

}

It will help you...

#Laravel 7

#Laravel

#Laravel 6