Laravel Eloquent Multiple Where Condition Example

Laravel 6 , Laravel , Laravel 7

Nicesnippets

16587

09-01-2020


Hi Guys

In this blog,i will tell you how to create multiple where clause query in laravel. we are exmaple multiple where clause query. you can easy create eloquent multiple where condition using laravel.it will show multiple where in laravel.

it can create multiple where clause query for two then ways available. you will learn

multiple where clause query.

There are two way create multiple where clause query in laravel.one way using multiple where clause function using query and second way is single where clause function in array passing.

here blow example of multiple where clause query.

Example 1


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

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);

}

It wil help you..


Recommended Posts