Laravel Where Like eloquent Query Example

Laravel Where Like eloquent Query Example

In this example you learn laravel where like eloquent query example. Today we will discuss about on laravel where like eloquent.  In this post i explain step by step laravel where like query.

In laravel, using whereLike() eloquent method, you can implement laravel where like search query, laravel where like multiple columns and laravel collection with where like.

Read Also :  Laravel Arr has() function Example

Laravel Where Like Eloquent Query

Example 1: Laravel Where Like Query

public function index()
{
    $search = "sanket";
    
    $users = User::where('name', 'LIKE', "%$search%")
                ->latest()
                ->get();
    dd($users);
}

Example 2: Laravel Where Like Query

public function index()
{
    $search = "sanket";
    
    $users = User::where('name', 'LIKE', "%{$search}%")
                ->latest()
                ->get();
    dd($users);
}

Example 3: Laravel Where Like Query

public function index()
{
    $search = "sanket";
    
    $users = User::where('name', 'LIKE','%' . $search . '%')
                ->latest()
                ->get();
    dd($users);
}

I hope you understand of laravel where like eloquent and it can help you…