I am trying to write a function that will get all the "buckets" that are assigned auth'd userand / or buckets that don't have assigned users.
Relations, etc. work as they should. Am I missing something?
How can I get all users that are also assigned by the user, and also include buckets where no user is assigned (including the auth user).
- Buckets user assigned
- Buckets where users are assigned NO . that is, the pivot table does not contain rows for the bucket, etc.
My problem is most likely related to the request orWhere...
$buckets = Team::currentTeam()->buckets()->with('user')->whereHas('user', function($query) {
$query->where('user_id', Auth::user()->id)
->orWhere('user_id', function() {
$query->count();
}, '<', 0);
})->get();