PHP code example of divineomega / thisishowirole
1. Go to this page and download the library: Download divineomega/thisishowirole 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/ */
divineomega / thisishowirole example snippets
use JordJD\ThisIsHowIRole\RolesTrait as Roles; // <-- Line 1
class User
{
use Roles; // <-- Line 2
public $id = 123;
}
$user = new User;
$user->roles->add('can_eat_cake');
$user->roles->add('can_eat_cookies');
$user->roles->remove('can_eat_cookies');
echo 'This user can ';
if ($user->roles->has('can_eat_cake')) {
echo 'eat cakes... ';
}
if ($user->roles->has('can_eat_cookies')) {
echo 'eat cookies... ';
}
echo "\n";