I would like to have this kind of query in Eloquent:
SELECT * FROM table WHERE status = 1 AND (type = 2 OR type = 3 OR type = 4)
I\'ve been
To group where clauses like that, you need to pass a closure to the where()
method, and add your grouped conditions inside the closure. So, your code would look something like:
Table::where('status', 1)->where(function ($q) {
return $q->where('type', 2)->orWhere('type', 3)->orWhere('type', 4);
});
This will generate the SQL:
SELECT * FROM tables WHERE status = 1 AND (type = 2 OR type = 3 OR type = 4)