PHP code example of wilsonalencar / laravel-permission

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

    

wilsonalencar / laravel-permission example snippets


Leandreaci\LaravelPermission\LaravelPermissionServiceProvider::class

'Permission' => Leandreaci\LaravelPermission\Facade\LaravelPermission::class,

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Leandreaci\LaravelPermission\Traits\Authorizable;

class User extends Authenticatable
{
    use Notifiable;
    use Authorizable;


    use Leandreaci\LaravelPermission\Facade\Permission;

    class FooController
    {
        public function index()
        {
            if(! Permission::can('view.foo'))
            {
                //do what you want ;)
            }
        }
    }

php artisan vendor:publish
php artisan migrate