Reputation: 53
I'm using spatie package for roles and permissions in my laravel project, I need to list all roles with their permissions in a table, is there is any way?
[
{
id:1,
name:"role1",
"permissions":[
{
"id":1,
"name":"Permission 1"
},
{
"id":2,
"name":"Permission 2",
}
]
}
]
Upvotes: 3
Views: 12228
Reputation: 989
Got it with this:
$role_permissions = Role::with('permissions')->get();
(answered by questioner)
Upvotes: 11