1. Go to this page and download the library: Download signes/acl 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/ */
/**
* Create and Save example Group
*/
$group = new \App\Models\Acl\Group();
$group->setName('MyGroup1')->save();
/**
* Create and save example Roles
*/
$role1 = new \App\Models\Acl\Role();
$role1->setName('My Role 1')->save();
$role2 = new \App\Models\Acl\Role();
$role2->setName('My Role 2')->save();
$role3 = new \App\Models\Acl\Role();
$role3->setName('My Role 3')->setFilter('R')->save();
/**
* Create and save example permissions
*/
$permission1 = \Acl::createPermission('zone1', 'access1', ['act1', 'act2', 'act3'], 'Zone 1');
$permission2 = \Acl::createPermission('zone2', 'access2', ['act1', 'act2', 'act3'], 'Zone 2');
$permission3 = \Acl::createPermission('zone3', 'access3', ['act1', 'act2', 'act3'], 'Zone 3');
/**
* When we have ready entity lets connect them
*/
$guestUser = \App\Models\Acl\User::find(1);
$guestUser->setGroup($group)->save()
// Connect user with permissions
\Acl::grantUserPermission($permission1, $guestUser, ['act1']);
\Acl::grantUserPermission($permission2, $guestUser, ['act1', 'act2', 'act3']);
// Connect group with permissions
\Acl::grantGroupPermission($permission1, $group, ['act3']);
// Connect roles with permissions
\Acl::grantRolePermission($permission3, $role1, ['act1']);
\Acl::grantRolePermission($permission1, $role2, ['act2']);
\Acl::grantRolePermission($permission2, $role3, ['act2']);
// Connect user with roles
\Acl::grantUserRole($role2, $guestUser);
\Acl::grantUserRole($role3, $guestUser);
// Connect group with roles
\Acl::grantGroupRole($role1, $group);
\Acl::grantGroupRole($role2, $group);