bfe / laravel-permission
Permission handling for Laravel 6.0 and up
Fund package maintenance!
spatie
Requires
- php: ^7.3|^8.0|^8.1
- illuminate/auth: ^7.0|^8.0|^9.0
- illuminate/container: ^7.0|^8.0|^9.0
- illuminate/contracts: ^7.0|^8.0|^9.0
- illuminate/database: ^7.0|^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ^5.0|^6.0|^7.0
- phpunit/phpunit: ^9.4
- predis/predis: ^1.1
This package is not auto-updated.
Last update: 2024-05-09 22:52:21 UTC
README
Documentation, Installation, and Usage Instructions
To get started with using the package, we'll install it using the following command:
composer require bfe/laravel-permission
Now that we've installed the package, we'll need to publish the database migration and config file:
php artisan vendor:publish --provider="Bfe\Permission\PermissionServiceProvider"
We can now run the migrations to create the new tables in our database:
php artisan migrate
Assuming that we are using the default config values and haven't changed anything in the package's config/permission.php, we should now have five new tables in our database:
What It Does
This package allows you to manage user permissions and roles in a database.
Once installed you can do stuff like this:
// Adding permissions to a user $user->givePermissionTo('edit articles'); // Adding permissions via a role $user->assignRole('writer'); $role->givePermissionTo('edit articles');
Because all permissions will be registered on Laravel's gate, you can check if a user has a permission with Laravel's default can
function:
$user->can('edit articles');
Testing
composer test