sammaye/laravel-permission is a Laravel package for a quick laravel permissions plugin.
It currently has 0 GitHub stars and 26 downloads on Packagist.
Install it with composer require sammaye/laravel-permission.
Discover more Laravel packages by sammaye
or browse all Laravel packages to compare alternatives.
Last updated
Really simple permissions (RBAC) plugin for Laravel.
You can find the configuration in config/sammaye.permission.php and it is called like config('sammaye.permission.permissions') to get a list of configured default permissions.
Add content to the permissions key, arrays will be translated into roles and the elements into permissions.
If you're not using the default User model then you change the user key.
User TraitAdd sammaye\Permission\Traits\HasPermission to your user model.
You're done.
permission:refreshWill sync the permissions in your database with those in your configuration, so if you add new role and/or permissions in your configuration they will be reflected in your database.
permission:permission {name} {user_id?}Will create a permission, if not existing, and assign it to a user, if supplied.
permission:role {name} {user_id?}Will create a role, if not existing, and assign it to a user, if supplied.
permission:role-permission {role_id} {permission_id}Will assign a role to a permission, will not create either if they do not exist.
You can easily replace rules from the database with your own gate, like so:
Gate::define('update-post', function(User $user, Post $post){
return $user->hasPermission('edit-post') && $user->id === $post->user_id;
});
JOINs