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


0 Comments

Leave a Reply

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