23 lines
587 B
PHP
Executable File
23 lines
587 B
PHP
Executable File
<?php
|
|
namespace App\Support;
|
|
|
|
use App\Models\User;
|
|
|
|
class ModuleVisibility
|
|
{
|
|
public static function isGesconInternalVisible(): bool
|
|
{
|
|
return (bool) config('netgescon.modules.gescon_internal_visible', app()->environment('local'));
|
|
}
|
|
|
|
/**
|
|
* @param array<int, string> $roles
|
|
*/
|
|
public static function canAccessGesconInternal(?User $user, array $roles = ['super-admin', 'admin', 'amministratore', 'collaboratore']): bool
|
|
{
|
|
return self::isGesconInternalVisible()
|
|
&& $user instanceof User
|
|
&& $user->hasAnyRole($roles);
|
|
}
|
|
}
|