PHP code example of abdul / laravel-role-permission

1. Go to this page and download the library: Download abdul/laravel-role-permission 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/ */

    

abdul / laravel-role-permission example snippets


Route::group([
    'middleware' => 'auth.role',
    'prefix' => 'config',
    'module' => 'Role',
    'role' => 'admin',
    ...
],function (){
    Route::get('/roles', 'RoleController@index');
});

Role::firstOrCreate(['name' => 'admin']);
Role::firstOrCreate(['name' => 'customer']);

use Abdul\RolePermission\Models\Role;

$ php artisan migrate

$ php artisan permissions:generate 

$ php artisan permissions:generate --fresh

$ php artisan permissions:clear

$ php artisan permissions:clear --roles role1 role2

$ php artisan permissions:clear --tables permissions

$ php artisan permissions:clear --tables roles

$ php artisan permissions:clear --tables permission_role

$ php artisan permissions:clear --roles admin --tables permission_role