Laravel UsersAdmin
This package creates DB table user_roles and serves CRUD pages of users in administrative panel included its roles.
The package includes facade to operate user's role.
It includes a ServiceProvider to register the package and attach it to the output., (*1)
Installation
Add the package to root composer.json:, (*2)
"require": {
...
"vadiasov/users-admin": "^1.0.0",
}
Then run:, (*3)
composer update
Register package in config/app.php, (*4)
'providers' => [
/*
* Package Service Providers...
*/
Vadiasov\UsersAdmin\UserServiceProvider::class,
Create model:, (*5)
php artisan make:model User_role
Publish migrations and seeds. Run:, (*6)
php artisan vendor:publish
and enter appropriate number of this package (see terminal output after last command)., (*7)
Migrate:, (*8)
php artisan migrate
Seed if you need demo data:, (*9)
php artisan db:seed class=UserRolesSeeder
Routes
The routes are in the package:, (*10)
admin/users
admin/users/create
admin/users/{id}/edit
admin/users/{id}/delete
Methods
UsersAdmin::hasRole($userId, $roleId)
UsersAdmin::setRole($userId, $roleId) (will be created later)