I got the following:
User, Role, with a role_user pivot table and a belongsToMany relationship
User, Location, with a location_user pivot table and a belongsToMany relationship
There's 2 roles for the user: owner & worker
Location has a 'workers_max' field
I try to build a query to get All locations where 'workers_max' is greater than number of associated workers.
I tried:
Locations::withCount('workers')->where('workers_max', '>', 'workers_count')->get();
but it returns all the locations.