bfe/laravel-permission

Permission handling for Laravel 6.0 and up

0.0.1 2022-11-22 10:20 UTC

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