How can I count for example the number of roles for a user?
When I try this:
User::with('roles')->count(); it just counts the number of users.
What I need is to return the number of roles per user. For example:
[ { "id": 2, "name": "user", "roles": 2 }, { "id": 3, "name": "user", "roles": 1 } ]