Complex queries using Eloquent Query in Laravel

Using Eloquent Queries are easy and helpful  but what will you do when you need to do  a complex query like "select fields from table  where (a=1 OR b=1)AND (c=1 OR d=1);"

You can make use of the parameter grouping which is a grouping constraint within parenthesis.

$a='1', $b='1', $c='1', $d='1';

Model::where(function ($query) use ($a, $b) {

    $query->where('a', '=', $a)

          ->orWhere('b', '=', $b);

})->where(function ($query) use ($c, $d) {

          $query->where('c', '=', $c)

              ->orWhere('d', '=', $d);

           })->get();