In Eloquent, I'd like to generate this query:
SELECT * FROM table WHERE a=1 AND ( b=2 OR c=3 );
But I seem to be generating this query instead:
SELECT * FROM table WHERE a=1 AND b=2 OR c=3;
Here is my implementation and code:
$result = Model::aIsOne()->bIsTwoOrCIsThree()->get();
Model contains:
function scopeAIsOne($query) {
return $query->where('a', 1);
}
function scopeBIsTwoOrCIsThree($query) {
return $query->where('b', 2)->orWhere('c', 3);
}