In Eloquent, you can combine whereHas()
and orDoesntHave()
in one sentence.
User::whereHas('roles', function($query) { $query->where('name', 'Admin');})->orDoesntHave('roles')->get();
Only until Jan 16th: coupon RESOLUTION25 for 40% off Yearly/Lifetime membership!
Read more hereIn Eloquent, you can combine whereHas()
and orDoesntHave()
in one sentence.
User::whereHas('roles', function($query) { $query->where('name', 'Admin');})->orDoesntHave('roles')->get();