Skip to content

Instantly share code, notes, and snippets.

@richardDobron
Created July 14, 2022 15:48
Show Gist options
  • Save richardDobron/aa4207654f63540614a9e0c9ab31e4fb to your computer and use it in GitHub Desktop.
Save richardDobron/aa4207654f63540614a9e0c9ab31e4fb to your computer and use it in GitHub Desktop.
<?php
use App\Enums\UserRoleTypes;
class User
{
// ...
public function hasRole(int $roleId): bool
{
return $this->roleId === $roleId;
}
public function isAnalyst(): bool
{
return $this->roleId === UserRoleTypes::INSIGHTS_ANALYST;
}
}
// ...
$user->hasRole(UserRoleTypes::MANAGER);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment