This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. This package is a cool livewire GUI for Spatie Laravel Permission (not included), and it will help you to:
- Create role.
- Create permission.
- Assign role to user.
- Give permission to role.
- Assign role to permission.
- Remove permission from role.
All this via 3 livewire components that will show you the information in a dynamic table which is searchable, sortable and filtered.
You can install the package via composer:
composer require ihabafia/permissions-admin
- This package is depend on Spatie Laravel Permission, to install it if you didn't already:
composer require spatie/laravel-permission
- Livewire is required, to install it if you didn't already:
composer require livewire/livewire
- You need to create and empty
App\Models\Role
andApp\Models\Permission
class and addHasPermissionAdmin
trait as follows:
namespace App\Models;
use IhabAfia\PermissionsAdmin\Traits\HasPermissionAdmin;
use Spatie\Permission\Models\Role as SpatieRole;
class Role extends SpatieRole
{
use HasPermissionAdmin;
}
namespace App\Models;
use IhabAfia\PermissionsAdmin\Traits\HasPermissionAdmin;
use Spatie\Permission\Models\Permission as SpatiePermission;
class Permission extends SpatiePermission
{
use HasPermissionAdmin;
}
These classes will not affect your application since these classes extends the original class.
- You need to add
HasPermissionAdmin
trait in yourUser::class
like follows:
namespace App\Models;
use Spatie\Permission\Traits\HasRoles;
use IhabAfia\PermissionsAdmin\Traits\HasPermissionAdmin;
class User extends Authenticatable
{
use HasRoles;
use HasPermissionAdmin;
...
}
This trait is needed for adding the search functionality to the 3 models.
- Finally, you need to use this route in
web.php
Route::rolesPermissionsAdmin();
You might need to publish the config file to change default routes with your own:
php artisan vendor:publish --tag="permissions-admin-config"
Optionally but recommended, you can publish the views using the command bellow, to make sure you get the correct styling of all the component.
php artisan vendor:publish --tag="permissions-admin-views"
Need Help
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.