Laravel Multiple Where Condition Example

Laravel Multiple Where Condition Example

In this post we will give you information about Laravel Multiple Where Condition Example. Hear we will give you detail about Laravel Multiple Where Condition ExampleAnd how to use it also give you demo for it if it is necessary.

Today, i teach you how to write multiple where clause in laravel query builder. i will give you example of laravel eloquent multiple where conditions. you can easily execute multiple where condition in laravel query.

Almost, we need to write multiple where condition with laravel. as we know we can use where clause using where() in laravel. but if you want to write multiple where clause in laravel then i will give you two example of how to write multiple where clause in laravel.

You can see both syntax of writing multiple where condition:

->where('COLUMN_NAME', 'OPERATOR', 'VALUE')

->where('COLUMN_NAME', 'OPERATOR', 'VALUE')

OR

->where([

['COLUMN_NAME', 'OPERATOR', 'VALUE'],

['COLUMN_NAME', 'OPERATOR', 'VALUE']

]);

Now i will give you example of how to write multiple where condition with laravel.

If you have sql query like as bellow with multiple where condition:

SQL Query:

SELECT * FROM 'users'

WHERE active = 1 AND is_ban = 0

Then you can write your sql qurey like as bellow both way:

Example 1:

public function index()

{

$users = User::select('*')

->where('active', '=', 1)

->where('is_ban', '=', 0)

->get();

dd($users);

}

Example 2:

public function index()

{

$users = User::select('*')

->where([

['active', '=', 1],

['is_ban', '=', 0]

])

->get();

dd($users);

}

I hope it can help you…

Hope this code and post will helped you for implement Laravel Multiple Where Condition Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

2  +  7  =  

We accept paid advance and paid guest Posting on our Site : Contact US