I have a M-M relationship on User and Roles. Also, one User belongs to Clinic. I would like to filter out all users belonging to one role, which have specific clinic_id. I am trying with this one but it doesn't work:
$user = Role::where('name', 'admin')->first()
->users->where('clinic_id', Auth::user()->clinic_id)->get();
I am getting an error on this one
Type error: Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in
Relationship is defined fine, and if I exclued the with() I get back all users who are admins.
via Norgul