Posted inphp / Laravel

multiple where condition in laravel

Laravel Multiple Where Condition Example

syntax

->where('COLUMN_NAME', 'OPERATOR', 'VALUE')
->where('COLUMN_NAME', 'OPERATOR', 'VALUE')
->where([
        ['COLUMN_NAME', 'OPERATOR', 'VALUE'],
        ['COLUMN_NAME', 'OPERATOR', 'VALUE']
    ]);

SQL Query:

SELECT * FROM `members` WHERE status = 1 AND app_flag = 0

Examople 1:

public function index()
{
    $members = Member::select('*')
                ->where('status', '=', 1)
                ->where('app_flag', '=', 0)
                ->get();
   
    dd($members);
}

Example 2:

public function index()
{
    $members = Member::select('*')
                ->where([
                    ['status', '=', 1],
                    ['app_flag', '=', 0]
                ])
                ->get();
   
    dd($members);
}

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype