apply the school year concept
Tests / PHPUnit (push) Failing after 1m19s

This commit is contained in:
root
2026-07-14 00:59:00 -04:00
parent 504c3bc9f9
commit feb1b29a32
73 changed files with 4288 additions and 620 deletions
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Services;
final class SchoolYearAccessPolicy
{
public function canView(?int $userId, array $year): bool
{
if (($year['status'] ?? '') !== 'draft') {
return true;
}
return $this->canViewDraft($userId);
}
public function canSelect(?int $userId, array $year): bool
{
return $this->canView($userId, $year);
}
public function canViewDraft(?int $userId): bool
{
if ($userId === null || $userId <= 0) {
return false;
}
$roles = array_map(
static fn ($role): string => strtolower(trim((string) $role)),
(array) session()->get('roles')
);
return (bool) array_intersect($roles, [
'admin',
'administrator',
'administrative staff',
'principal',
]);
}
}