Muhammed Musthafa KP
Muhammed Musthafa KP

Reputation: 53

How to list all roles with Permissions,in spatie permission Package?

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

Answers (1)

JorisJ1
JorisJ1

Reputation: 989

Got it with this:

$role_permissions = Role::with('permissions')->get();

(answered by questioner)

Upvotes: 11

Related Questions