Laravel Package for Role Management. This package uses the Spatie Laravel Permission package and includes role CRUD functionality & Seeder for permission.
sudippalash/role-creator is a Laravel package for laravel package for role management. this package uses the spatie laravel permission package and includes role crud functionality & seeder for permission..
It currently has 1 GitHub stars and 367 downloads on Packagist (latest version 1.2.6).
Install it with composer require sudippalash/role-creator.
Discover more Laravel packages by sudippalash
or browse all Laravel packages to compare alternatives.
Last updated

role-creator is a role management package of Laravel that provides options to manage role for auth users.
Note: This package is wrapper of spatie/laravel-permission package.
Via Composer
composer require sudippalash/role-creator
You should publish
migrations files:
database/migrations/create_permission_tables.phpdatabase/migrations/add_module_column_to_permissions_table.php,config files:
config/permission.php,config/role-creator.phpand seeders file:
database/seeders/PermissionSeeder.phpwith:
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=required
For config/permission.php file you should check spatie/laravel-permission package documentation.
This is the contents of the published config file config/role-creator.php:
return [
/*
|--------------------------------------------------------------------------
| Extends Layout Name
|--------------------------------------------------------------------------
|
| Your main layout file path name. Example: layouts.app
|
*/
'layout_name' => 'layouts.app',
/*
|--------------------------------------------------------------------------
| Section Name
|--------------------------------------------------------------------------
|
| Your section name which in yield in main layout file. Example: content
|
*/
'section_name' => 'content',
/*
|--------------------------------------------------------------------------
| Route Name, Prefix & Middleware
|--------------------------------------------------------------------------
|
| Provide a route name for role route. Example: user.roles
| Provide a prefix name for role url. Example: user/roles
| If role route use any middleware then provide it or leave empty array. Example: ['auth']
*/
'route_name' => 'user.roles',
'route_prefix' => 'user/roles',
'middleware' => [],
/*
|--------------------------------------------------------------------------
| Role & Permission Name Pretty Print
|--------------------------------------------------------------------------
|
| You can set the delimiter to separate your role/permission name for pretty preview
| Example: array('-', '_', '=', '|', '/')
|
*/
'role_permission_name_separator' => ['-', '_'],
/*
|--------------------------------------------------------------------------
| Auth Guard Name
|--------------------------------------------------------------------------
|
| Which authentication guard you use for role. Example: web or admin
|
*/
'auth_guard_name' => 'web',
/*
|--------------------------------------------------------------------------
| Role Prevent
|--------------------------------------------------------------------------
|
| Those role names hide from list and prevent from edit & delete. Example ['Super Admin']
|
*/
'hide_role_names' => [],
/*
|--------------------------------------------------------------------------
| Bootstrap version
|--------------------------------------------------------------------------
|
| Which bootstrap you use in your application. Example: 3 or 4 or 5
|
*/
'bootstrap_v' => 4,
/*
|--------------------------------------------------------------------------
| Flash Messages
|--------------------------------------------------------------------------
|
| After Save/Update flash message session key name
|
*/
'flash_success' => 'success',
'flash_error' => 'error',
/*
|--------------------------------------------------------------------------
| CSS
|--------------------------------------------------------------------------
|
| Add your css class in this property if you want to change design.
*/
'css' => [
'container' => null,
'card' => null,
'input' => null,
'btn' => null,
'table' => null,
'table_action_col_width' => null,
'table_action_btn' => null,
],
];
Optionally, you can publish the views using
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=views
Optionally, you can publish the lang using
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=lang
You should run the migrations with:
php artisan migrate
In database/seeders/PermissionSeeder.php seed file you should set your permission data and then you should run the seed with:
php artisan db:seed --class=PermissionSeeder
You should copy the below line and paste in your project menu section
<a href="{{ route(config('role-creator.route_name').'.index') }}">{{ trans('role-creator::sp_role_creator.roles') }}</a>
use Sudip\RoleCreator\Traits\RoleCrud;
class YourController extends Controller
{
use RoleCrud;
protected $guardName;
protected $routeName;
protected $hideRoles;
public function __construct()
{
$this->guardName = '{your guard_name}';
$this->routeName = '{your resource route name}';
$this->hideRoles = '{if you want to hide any roles}';
}
}