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;