Hey, Hope you're doing well.
I tried many times to retrieve all the records of the permissions table by using the query builder and eloquent. But in both cases, the permission table returns an empty array.
I wanna display roles as shown in the snapshot.

So, how I can retrieve the records?
There is no magic involved here, Permission::all() should (and does for me) work perfectly fine.
Yes, Permission::all() will return all the permission records.
@drbyte I get empty array if I write this:
auth()->user()->getPermissionNames()
But if I write this, i get collection of permissions:
auth()->user()->getAllPermissions()
why it is not returning permission names only?
@drbyte I get empty array if I write this:
auth()->user()->getPermissionNames()
But if I write this, i get collection of permissions:
auth()->user()->getAllPermissions()why it is not returning permission names only?
getPermissionNames() only returns direct permissions assigned to the user, not those inherited by associated roles.
However, getAllPermissions() goes and inspects the roles as well. So you could get the names from that by using getAllPermissions()->pluck('name');
Most helpful comment
There is no magic involved here,
Permission::all()should (and does for me) work perfectly fine.