PHP code example of thinkingmik / acl-manager-laravel
1. Go to this page and download the library: Download thinkingmik/acl-manager-laravel 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/ */
thinkingmik / acl-manager-laravel example snippets
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'system_users',
acl:role.resource.permission //check if logged user has role and the permission on resource
acl:*.resource.permission //check if logged user has permission on resource
acl:role.* //check if logged user has role
acl:role.resource.* //check if logged user has role and any permissions on resource
acl:*.resource.* //check if logged user has any permissions on resource
acl:admin.*;guest.*
/**
* Check if user ID has a specified policy/policies
* @param integer $user User ID
* @param string $policies The policies used in routing
* return boolean
**/
Acl::isRouteAllowed(1, 'admin.*;guest.*');
/**
* Check if user has permission on resource
* @param array $users Array of user objects or array of user IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* return boolean
**/
Acl::isAllowed(array(1), array('post', 'dashboard'), array('edit', 'view'));
/**
* Check if role has permission on resource
* @param array $roles Array of role objects or array of role IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* return boolean
**/
Acl::areAnyRolesAllowed(array(1), array('post', 'dashboard'), array('edit', 'view'));
/**
* Check if user has roles
* @param array $users Array of user objects or array of user IDs
* @param array $roles Array of role objects or array of role IDs
* return boolean
**/
Acl::hasRole(array(1), array('1', '2'));
/**
* Add permissions on resources for users specified
* @param array $users Array of user objects or array of user IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* @param date [$expire] Optionally you can specify an expiration date for policies
* return boolean
**/
Acl::allowUsers(array(1), array('post', 'dashboard'), array('edit', 'view'), '2099-11-01');
/**
* Add permissions on resources for roles specified
* @param array $roles Array of role objects or array of role IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* @param date [$expire] Optionally you can specify an expiration date for policies
* return boolean
**/
Acl::allowRoles(array(1), array('post', 'dashboard'), array('edit', 'view'), '2099-11-01');
/**
* Remove permissions on resources for users specified
* @param array $users Array of user objects or array of user IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* return integer The number of deleted policies
**/
Acl::denyUsers(array(1), array('post', 'dashboard'), array('edit', 'view'));
/**
* Remove permissions on resources for roles specified
* @param array $roles Array of role objects or array of role IDs
* @param array $resources Array of resource objects or array of resource IDs
* @param array $permissions Array of permission objects or array of permission IDs
* return integer The number of deleted policies
**/
Acl::denyRoles(array(1), array('post', 'dashboard'), array('edit', 'view'));
/**
* Add roles to users
* @param array $users Array of user objects or array of user IDs
* @param array $roles Array of role objects or array of role IDs
* @param char [$main] Optionally you can specify the main role
* return boolean
**/
Acl::addUsersRoles(array(1), array('1', '2'), 'Y');