From 445eec394dc02fe1f82204b946841f00c0557689 Mon Sep 17 00:00:00 2001 From: Dr Masroor Ehsan Date: Sun, 12 Jan 2025 10:10:43 +0600 Subject: [PATCH] refx --- app/Services/Report/ReportManager.php | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Services/Report/ReportManager.php b/app/Services/Report/ReportManager.php index 18c8658..ab89cd6 100644 --- a/app/Services/Report/ReportManager.php +++ b/app/Services/Report/ReportManager.php @@ -19,11 +19,6 @@ public static function make(int $study_id, ?StudyReport $report = null): static return new self(Study::findOrFail($study_id), $report); } - public function getReports(): Collection - { - return $this->study->reports->sortByDesc('created_at'); - } - public static function fromReport(string $uuid): static { $report = StudyReport::accession($uuid)->select(['id', 'study_id', 'file_path', 'created_at'])->firstOrFail(); @@ -31,6 +26,21 @@ public static function fromReport(string $uuid): static return static::make($report->study_id, $report); } + public static function ensureDownloadAccess(): void + { + abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove, Permission::ReportDownload]), 403); + } + + public static function ensureEditAccess(): void + { + abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403); + } + + public function getReports(): Collection + { + return $this->study->reports->sortByDesc('created_at'); + } + public function createReport(string $content, ReportStatus $status): StudyReport { $report = StudyReport::make([ @@ -124,16 +134,6 @@ public function getStudy(): Study return $this->study; } - public static function ensureDownloadAccess(): void - { - abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove, Permission::ReportDownload]), 403); - } - - public static function ensureEditAccess(): void - { - abort_unless(me()->may([Permission::ReportEdit, Permission::ReportDictate, Permission::ReportApprove]), 403); - } - public function getReport(): ?StudyReport { return $this->report;