PHP code example of onix-systems-php / hyperf-impersonate
1. Go to this page and download the library: Download onix-systems-php/hyperf-impersonate 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/ */
onix-systems-php / hyperf-impersonate example snippets
use OnixSystemsPHP\HyperfImpersonate\Contract\Impersonatable as ImpersonatableInterface;
use OnixSystemsPHP\HyperfImpersonate\Trait\Impersonatable;
class User extends ... implements ImpersonatableInterface
{
use Impersonatable;
}
public function canImpersonate(): bool
{
return in_array($this->getRole(), UserRoles::GROUP_ADMINS);
}
public function canBeImpersonated(): bool
{
return in_array($this->getRole(), UserRoles::GROUP_USERS);
}