PHP code example of beartropy / permissions

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

    

beartropy / permissions example snippets


use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}

// config/beartropy-permissions.php
return [
    'prefix' => 'permissions',
    'middleware' => ['web', 'auth', 'can:manage-permissions'],
    'gate' => 'manage-permissions',
    'user_model' => App\Models\User::class,
    'guards' => ['web'],
    'default_guard' => 'web',
    'user_display_field' => 'name',
    'user_search_fields' => ['name', 'email'],
    'group_permissions' => true,
    'permission_group_separator' => '.',
];
bash
composer vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate
bash
php artisan vendor:publish --tag=beartropy-permissions-config
bash
php artisan vendor:publish --tag=beartropy-permissions-views
bash
php artisan vendor:publish --tag=beartropy-permissions-lang