23 lines
850 B
PHP
23 lines
850 B
PHP
<?php
|
|
|
|
namespace App\Modules\Services;
|
|
|
|
final class ServicePermissions
|
|
{
|
|
public const AREAS = ['clients', 'services', 'service_drafts', 'billing_drafts'];
|
|
public const ACTIONS = ['view', 'create', 'edit', 'manage'];
|
|
public const LABELS = ['clients' => 'Clientes', 'services' => 'Serviços', 'service_drafts' => 'Prestações em rascunho', 'billing_drafts' => 'Rascunhos de facturação'];
|
|
|
|
public static function unitScoped(string $area): bool { return in_array($area, ['service_drafts', 'billing_drafts'], true); }
|
|
public static function catalogue(bool $unit): array
|
|
{
|
|
$result = [];
|
|
foreach (self::AREAS as $area) {
|
|
if (self::unitScoped($area) === $unit) {
|
|
foreach (self::ACTIONS as $action) { $result[] = "$area.$action"; }
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
}
|