1. Go to this page and download the library: Download nh/access-control 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/ */
nh / access-control example snippets
php artisan vendor:publish --tag=access-control
// Request
hasAccess(string $model, mixed $actions = null, boolean $strict = false)
// Has ANY permission of the Role model
Auth::user()->hasAccess('role')
// Has ALL permission of the Role model
Auth::user()->hasAccess('role', null, true)
// Has a specific permission of the Role model
Auth::user()->hasAccess('role', 'update')
// Has ANY specific permission of the Role model
Auth::user()->hasAccess('role', ['update','delete'])
// Has ALL specific permission of the Role model
Auth::user()->hasAccess('role', ['update','delete'], true)
Auth::user()->permission_restrictions;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.