PHP code example of bozboz / permissions

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

    

bozboz / permissions example snippets


$permissions->define('manage_page', 'Bozboz\Permissions\Rules\Rule');
$permissions->define('delete_pages', 'Bozboz\Permissions\Rules\GlobalRule');

if (Gate::allows('delete_pages')) {
	$instance->delete();
}

if (app('permission.checker')->allows('delete_pages')) {
	$instance->delete();
}

if (Gate::forUser($user)->allows('delete_pages')) {
	$instance->delete();
}

if (Gate::forUser($user)->disallows('delete_pages')) {
	App::abort(403);
}

$instance->delete();

if (RuleStack::with('view_pages')->then('view_anything')->isAllowed()) {
	// User is able to view pages and/or view anything
}

$stack = new RuleStack;
$stack->add('edit_anything');
$stack->add('edit_page', 5);
return $stack->isAllowed();