Answers for "Laravel Eloquent Query Using WHERE with OR AND OR?"

PHP
0

Laravel Eloquent Query Using WHERE with OR AND OR?

Make use of Logical Grouping (Laravel 7.x/4.2). For your example, it'd be something like this:

Model::where(function ($query) {
    $query->where('a', '=', 1)
          ->orWhere('b', '=', 1);
})->where(function ($query) {
    $query->where('c', '=', 1)
          ->orWhere('d', '=', 1);
});
Posted by: Guest on March-14-2022

Code answers related to "Laravel Eloquent Query Using WHERE with OR AND OR?"

Browse Popular Code Answers by Language