PHP code example of vassilidev / laraperm

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

    

vassilidev / laraperm example snippets


return [
    'permissions' => [
        'super-admin' => env('LARAPERM_PERMISSION_SUPERADMIN', '*'),
    ]
];

Permission::create(['name' => 'edit posts']);

$role = Role::create(['name' => 'Publisher']);
$role->givePermissionTo('edit posts');

$user = User::factory()->create();
$publisher = User::factory()->create();

$user->declareAsSuperAdmin();
 $publisher->assignRole('Publisher');

dump($user->isSuperAdmin()); // True
dump($publisher->isSuperAdmin()); // False

dump($user->can('edit posts')); // True
dump($publisher->can('edit posts')); // True
bash
php artisan vendor:publish --provider="Vassilidev\Laraperm\LarapermServiceProvider"