Enforce task limits and update event form
This commit is contained in:
@@ -223,7 +223,7 @@ class PackageLimitEvaluator
|
||||
return $eventPackage;
|
||||
}
|
||||
|
||||
public function summarizeEventPackage(EventPackage $eventPackage): array
|
||||
public function summarizeEventPackage(EventPackage $eventPackage, ?int $tasksUsed = null): array
|
||||
{
|
||||
$limits = $eventPackage->effectiveLimits();
|
||||
|
||||
@@ -244,12 +244,22 @@ class PackageLimitEvaluator
|
||||
config('package-limits.gallery_warning_days', [])
|
||||
);
|
||||
|
||||
$taskSummary = $tasksUsed === null
|
||||
? null
|
||||
: $this->buildUsageSummary(
|
||||
$tasksUsed,
|
||||
$limits['max_tasks'],
|
||||
[]
|
||||
);
|
||||
|
||||
return [
|
||||
'photos' => $photoSummary,
|
||||
'guests' => $guestSummary,
|
||||
'gallery' => $gallerySummary,
|
||||
'tasks' => $taskSummary,
|
||||
'can_upload_photos' => $photoSummary['state'] !== 'limit_reached' && $gallerySummary['state'] !== 'expired',
|
||||
'can_add_guests' => $guestSummary['state'] !== 'limit_reached',
|
||||
'can_add_tasks' => $taskSummary ? $taskSummary['state'] !== 'limit_reached' : null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user