Hello.
I am trying to get all users that are not currently assigned to a location in a many to many relationship.
I have no clue on how I could aproach this.
Currently I am getting only the users that have no location at all. But I need to use the $location_id to filter the result.
public function getUnassignedUsersForLocation($location_id)
{
$users = User::select(['id', 'name'])
->has('locations', '=', 0)
->get();
return response()->json($users);
}
Any possible solutions?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community