first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user