3

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",
         }
      ]
   }
]
apokryfos
  • 38,771
  • 9
  • 70
  • 114

1 Answers1

11

Got it with this:

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

(answered by questioner)

JorisJ1
  • 922
  • 2
  • 12
  • 22