PHP code example of amir / laravel-permission

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

    

amir / laravel-permission example snippets


Route::group([
    'middleware' => 'auth.role',
    'prefix' => ...,
    'role' => ['admin', 'customer'],
    ...
],function (){
    ...
    Route::get('/home', 'HomeController@index')->name('home');
    Route::get('/product', 'ProductController@index');
    ...
});

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

use Amir\Permission\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