Files
verifikator/app/Helpers/RoleHelper.php
T
2026-08-07 10:47:09 +07:00

34 lines
787 B
PHP

<?php
use Illuminate\Support\Facades\Auth;
if (! function_exists('isSuperuser')) {
/**
* Check if the current authenticated user has the Superuser role.
*/
function isSuperuser(): bool
{
return Auth::check() && Auth::user()->hasRole('Superuser');
}
}
if (! function_exists('hasRole')) {
/**
* Check if the current authenticated user has the specified role.
*/
function hasRole(string $role): bool
{
return Auth::check() && Auth::user()->hasRole($role);
}
}
if (! function_exists('hasAnyRole')) {
/**
* Check if the current authenticated user has any of the specified roles.
*/
function hasAnyRole(array $roles): bool
{
return Auth::check() && Auth::user()->hasAnyRole($roles);
}
}