Laravel Multiple WHERE conditions – AND, OR, IN, NOT IN

Today, We want to share with you laravel where condition.In this post we will show you multiple where clause in laravel query builder., hear for laravel two where conditions we will give you demo and example for implement.In this post, we will learn about laravel eloquent multiple where conditions. with an example.

Laravel Multiple Where Condition Example

There are the Following The simple About multiple where condition with laravel Full Information With Example and source code.

. but if you want to added script multiple where clause in laravel then i will give you two example of how to added script multiple where clause in laravel.

Also Read This πŸ‘‰   WooCommerce Get Linked Products

As I will cover this Post with live Working example to develop where clause using where() in laravel application, so the multiple where clause in laravel query builder is used for this example is following below.

Also you can easily main 2 types of the execute or run multiple where condition in laravel query.

You can see both syntax of writing multiple where condition:

->where('YOUR_COLUMN_NAME', 'OPERATOR', 'USER_DYNAMIC_STATIC_VALUE')
->where('YOUR_COLUMN_NAME', 'OPERATOR', 'USER_DYNAMIC_STATIC_VALUE')

other Way

->where([
        ['YOUR_COLUMN_NAME', 'OPERATOR', 'USER_DYNAMIC_STATIC_VALUE'],
        ['YOUR_COLUMN_NAME', 'OPERATOR', 'USER_DYNAMIC_STATIC_VALUE']
    ]);

Here, i will give you best Laravel example of how to put multiple where condition with laravel web application.

Also Read This πŸ‘‰   Creating Laravel Web Installer Setup Wizard

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

Free Live Chat for Any Issue

Simple SQL Query:

SELECT * FROM `products` WHERE active = 1 AND is_sell = 0

and Then you can run your sql qurey like as following the both way:

Example 1: Create Multiple Where Clause Query Using Laravel Eloquent

public function index()
{
    $products = Product::select('*')
                ->where('active', '=', 1)
                ->where('is_sell', '=', 0)
                ->get();
   
    dd($products);
}

Example 2: Writing multiple where clause query

public function index()
{
    $products = Product::select('*')
                ->where([
                    ['active', '=', 1],
                    ['is_sell', '=', 0]
                ])
                ->get();
   
    dd($products);
}

Rate this post