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);
3 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.
Abdulhakim Zeinu · November 26, 2020 at 8:10 am
Thank you!!
Mohammed T. · March 26, 2021 at 5:16 am
Thats great. thank you for sharing