PHP code example of sudippalash / role-creator

1. Go to this page and download the library: Download sudippalash/role-creator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sudippalash / role-creator example snippets


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,
    ],
];
bash
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=
bash
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=views
bash
php artisan vendor:publish --provider="Sudip\RoleCreator\Providers\AppServiceProvider" --tag=lang
bash
php artisan migrate
bash
php artisan db:seed --class=PermissionSeeder
bash
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}';
    }
}