This commit is contained in:
Dr Masroor Ehsan 2025-01-12 10:10:43 +06:00
parent f746071bd7
commit 445eec394d

View File

@ -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;