diff --git a/app/Http/Controllers/HashedStudyControllerBase.php b/app/Http/Controllers/HashedStudyControllerBase.php index b36e653..80f365e 100644 --- a/app/Http/Controllers/HashedStudyControllerBase.php +++ b/app/Http/Controllers/HashedStudyControllerBase.php @@ -15,4 +15,14 @@ protected function getStudy(): Study return $this->study; } + + protected function lockedNotice() + { + return view('content.pages.notice', [ + 'title' => 'Study Locked', + 'color' => 'danger', + 'heading' => 'Study Locked', + 'message' => 'Study metadata cannot be edited once the report has been finalized.', + ]); + } } diff --git a/app/Http/Controllers/Staff/MetadataController.php b/app/Http/Controllers/Staff/MetadataController.php index 01053d9..86b36bd 100644 --- a/app/Http/Controllers/Staff/MetadataController.php +++ b/app/Http/Controllers/Staff/MetadataController.php @@ -23,14 +23,8 @@ public function edit() { abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); $study = $this->getStudy(); - if ($study->isReportReady()) { - return view('content.pages.notice', [ - 'title' => 'Study Locked', - 'color' => 'danger', - 'heading' => 'Study Locked', - 'message' => 'Study metadata cannot be edited once the report has been finalized.', - ]); + return $this->lockedNotice(); } return view('staff.meta.edit', compact('study')); @@ -40,7 +34,9 @@ public function save(StudyMetadataUpdateRequest $request) { abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); $study = $this->getStudy(); - abort_if($study->report_status->value >= ReportStatus::Finalized->value, 403); + if ($study->isReportReady()) { + return $this->lockedNotice(); + } $payload = array_trim_strings($request->validated()); $payload['body_part_examined'] = strtoupper($payload['body_part_examined']);