@Kenneth_H If a user will only ever have one role, then you can just do permission checking in your code:
$user->can(['edit-user', 'create-post']);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi I have been looking for a package that would help me enforcing permissions on user roles in my laravel 5 project. I came across this package in my search: https://github.com/Zizaco/entrust/tree/laravel-5 It semmes to be just what I am looking for in terms of how I want to run the check, but the way relations are done is not exactly what I want. In the documentation it says that a user can have many roles and roles can be assigned to many users. As my system will be based the roles having all permissions I will only assign one role for each user. The roles will the have multiple permissions, but the same permission can be assigned to multiple roles.
From the documentation it seems like this package can do, but it does not tell how to check if a user has a specific permission based on their role. Can this package handle this setup or will I need to make my own package for this?
Entrust::hasRole('role-name');
Entrust::can('permission-name');
// is identical to
Auth::user()->hasRole('role-name');
Auth::user()->can('permission-name);
if your role name is 'owner' using look like that.
if(Entrust::hasRole('owner')) {
//Do something
}
P.S. if you will create permission or roles dont use "-". use "_". if you will use "-", you will have problems.
Please or to participate in this conversation.