diff --git a/app/Http/Controllers/Staff/ReportController.php b/app/Http/Controllers/Staff/ReportController.php index 099c7a8..fc72606 100644 --- a/app/Http/Controllers/Staff/ReportController.php +++ b/app/Http/Controllers/Staff/ReportController.php @@ -57,9 +57,10 @@ public function create() abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403); $this->decodeKeys(); $study = Study::findOrFail($this->key); - if ($study->report_status >= ReportStatus::Finalized) { + if (! $study->canEditReport()) { return redirect()->back()->with('error', 'Report is already approved.'); } + $report = StudyReport::where('study_id', $study->id) ->where('report_status', ReportStatus::Preliminary->value) ->latest() diff --git a/app/Http/Requests/CreateReportRequest.php b/app/Http/Requests/CreateReportRequest.php index ceb2fb2..f6d13f0 100644 --- a/app/Http/Requests/CreateReportRequest.php +++ b/app/Http/Requests/CreateReportRequest.php @@ -20,10 +20,9 @@ public function rules(): array return [ 'hashid' => ['required', new ExistsByHash(Study::class)], 'content' => 'required', - 'report_status' => ['required', - - Rule::enum(ReportStatus::class) - ->only([ReportStatus::Preliminary, ReportStatus::Finalized, ReportStatus::Approved]), + 'report_status' => [ + 'required', + Rule::enum(ReportStatus::class)->only([ReportStatus::Preliminary, ReportStatus::Finalized, ReportStatus::Approved]), ], ]; } diff --git a/resources/views/staff/reports/create.blade.php b/resources/views/staff/reports/create.blade.php index d248981..64e92bd 100644 --- a/resources/views/staff/reports/create.blade.php +++ b/resources/views/staff/reports/create.blade.php @@ -26,12 +26,11 @@
@csrf -
- +
@@ -39,9 +38,9 @@ class="ck-editor editor-container editor-container_classic-editor editor-contain
-
-