PHP code example of parsampsh / simpermission

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

    

parsampsh / simpermission example snippets


$user->addPermission('what.i.want');
$user->deletePermission('what.i.want');
$user->getPermissions(); // ['foo.bar', 'hello.world'...]

if (! $user->hasPermission('some.thing')) {
    abort(403);
}

use Simpermission\HasPermissions;

class User
{
    // ...

    use HasPermissions;

    public function userIsManager()
    {
        return false;
    }

    // ...
}

class User
{
    // ...

    public function userIsManager()
    {
        // example
        return $this->is_manager === 1;
    }

    // ...
}
shell
$ php artisan migrate