Sometimes you may have multiple conditions while querying using Laravel Eloquent where clause. Here is the syntax how can you do it in a simple manner:

$users= User::where([
    ['column1', '=', 'value1'],
    ['column2', '<>', 'value2'],
    ...
]);

As you have seen above the only thing I do is to pass array of conditions. Also, you can have the condition array separately and use the array variable inside where method as follows.

$conditions = [['column1', '=', 'value1'],['column2', '<>', 'value2']
];
$users= User::where($conditions);


2 Comments

explanation latestbtcnews.com · November 17, 2020 at 9:11 pm

It is actually a great and useful piece of info. I’m glad that you shared this helpful information with us. Please stay us up to date like this. Thanks for sharing.

Leave a Reply

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