1. Go to this page and download the library: Download curlymoustache/sanction 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/ */
use Curlymoustache\Sanction\Sanction;
use Curlymoustache\Sanction\RoleLookup\SanctionArrayLookupProvider;
$rules = es' => ['admin']
],
[
'uid' => 32,
'name' => 'Bones',
'roles' => ['standard_user']
],
];
$sanction = new Sanction(
$rules,
null,
new SanctionArrayLookupProvider( // A simple array lookup class.
$users,
'uid' // Use `uid` as the unique user_id
)
);
// Now we can test these permissions to see if our rules hold true:
// Bones should be able to create users;
$sanction->userHasPermission(32, 'create_users'); // TRUE
// But not delete them:
$sanction->userHasPermission(32, 'delete_users'); // FALSE
// Where as Jim can delete them:
$sanction->userHasPermission(10, 'delete_users'); // TRUE
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use Curlymoustache\Sanction\Extensions\EloquentExtension;
...