PHP code example of akunbeben / fortify-role

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

    

akunbeben / fortify-role example snippets


'providers' => [
    ...
    App\Providers\FortifyServiceProvider::class,
],



namespace App\Models;

use Akunbeben\FortifyRole\Traits\HasRole;
...

class User extends Authenticatable
{
    use HasFactory, Notifiable, HasRole;
    ...
}

...
Route::group(['middleware' => ['auth', 'role:admin']], function () {
    
});

Route::group(['middleware' => ['auth', 'role:user']], function () {
    
});

php artisan vendor:publish --provider="Akunbeben\FortifyRole\FortifyRoleServiceProvider" --force

php artisan migrate --seed