In Eloquent, you can combine whereHas()
and orDoesntHave()
in one sentence.
1User::whereHas('roles', function($query) {2 $query->where('id', 1);3})4->orDoesntHave('roles')5->get();
In Eloquent, you can combine whereHas()
and orDoesntHave()
in one sentence.
1User::whereHas('roles', function($query) {2 $query->where('id', 1);3})4->orDoesntHave('roles')5->get();