Search code examples
laraveleloquentlaravel-permission

I receive an id of a Role and with that id I list all the permissions that are assigned to that role


Good Evening, it is possible that in SPATIE-LARAVEL-PERMISSION the following:

Some function or way that I receive an id of a Role and with that id I list all the permissions that are assigned to that role. I'm looking but I didn't find an answer. sorry for the inconvenience thank you


Solution

  • As described here in the docs, you can get all permissions of a role with the permissions relation

    use \Spatie\Permission\Models\Role;
    
    Role::find($id)->permissions;