Table of contents

Laravel Like Query

In this tutorial, we will tackle Laravel Like Query where clause using the like operator.


The Laravel Like Query is very useful when you are searching for a word or part of a word or paragraph in the column value.


For example, you are searching for users having john on their name.



namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class HomeController extends Controller

    * Display a listing of the resource.
    * @return \Illuminate\Http\Response
    public function index()
        $users = User::where('name', 'like', '%john%')->get();



%john% - searches exact value, the part between, part at the beginning, and part at the end.
%john - exact value, part at the end
john% - exact value, part at the beginning


I hope it helps you understand more about Laravel like() operator in where clause.

That's pretty much it.