PHP code example of winex01 / backpack-permission-manager

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

    

winex01 / backpack-permission-manager example snippets


//config/backpack/base.php

// The guard that protects the Backpack admin panel.
// If null, the config.auth.defaults.guard value will be used.
// 'guard' => 'backpack',
'guard' => null

//EntityCrudController.php
use Winex01\BackpackPermissionManager\Http\Controllers\Traits\UserPermissions;

public function setup()
{
    // some code here...
    
    // Option 1:
    $this->userPermissions('user'); // it will check all permission that starts with user_ (i recommend to use prefix such as: user_list, user_create and etc..)

    // Option 2:
    $this->userPermissions(); // if you follow roleName_permissionName and use the table's name as your roleName then you can leave it empty.

    // Option 3:
    // calling $this->userPermissions method is equivalent:
    $this->crud->denyAllAccess(); // if you want to use the checkAccess method dont forget to call denyAllAccess method first
    $this->checkAccess('users');
    $this->checkAccess('admin');
}


php artisan vendor:publish --provider="Winex01\BackpackPermissionManager\BackpackPermissionManagerServiceProvider" --tag="seeders"

php artisan db:seed --class=RolesAndPermissionsSeeder