Laravel Eloquent Multiple Where Condition Example

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
Laravel Eloquent Multiple Where Condition Example

Today now in this blog,i will show you how to create multiple where clause query in laravel application. Here i will give you an example of multiple where clause query. Here we can easy create an eloquent multiple where condition by using laravel. Here I will show you multiple where in laravel.

Here we can create multiple where clause query for two then ways available. So here from here you will learn multiple where clause queries.

Now there are two way to create multiple where clause query in laravel application. Then one way is by using multiple where clause function by using query and then the second way is single where clause functions in array passing.

Here we will see example of multiple where clause query.

Example 1

So here the example multiple where clause function using query.

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index(){
  $users  = User::where('id','>','2')
                ->where('birth_date','>','2000-01-01')
                ->get(); 
  dd($users);
}
Example 2

Now here the example single where clause function in array passing using query.

/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function index(){
 $posts =  \DB::table('posts')
              ->where([
                  ['category','=','1'],
                  ['view','>','49']
              ])
              ->get();
  dd($posts);
}

Read Also : Laravel 8 Eloquent Global Scope Tutorial Example

I hope it will help you. Also you can follow us on Facebook

About code chef

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 code chef →