This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exceptions\SchoolYear\SchoolYearWriteConflictException;
|
||||
use App\Support\SchoolYear\SchoolYearContext;
|
||||
use RuntimeException;
|
||||
|
||||
final class SchoolYearWriteGuard
|
||||
{
|
||||
@@ -12,14 +12,14 @@ final class SchoolYearWriteGuard
|
||||
bool $allowDraftForAdmin = false,
|
||||
bool $isAdmin = false
|
||||
): void {
|
||||
if ($context->status() === 'active') {
|
||||
if (strtolower($context->status()) === 'active') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($context->status() === 'draft' && $allowDraftForAdmin && $isAdmin) {
|
||||
if (strtolower($context->status()) === 'draft' && $allowDraftForAdmin && $isAdmin) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException('The selected school year is read-only.');
|
||||
throw new SchoolYearWriteConflictException('The selected school year is read-only.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user