PHP code example of msr / laravel-permission-block

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

    

msr / laravel-permission-block example snippets


$user->blockedPermissions // all permissions are blocked for user

// Block user from permission
$user->blockFromPermission('edit articles');
$user->blockFromPermission(['edit articles','view post']);

$user->hasBlockFromPermission('edit articles'); // return true
$user->hasDirectPermission('edit articles'); // return false
$user->hasPermissionTo('edit articles'); // return false
$user->can('edit articles'); // return false

$user->hasBlockFromAnyPermission(['edit article','view post']) // return true if any of passing permissions array are blocked

$user->unblockFromPermission('view post')