diff --git a/app/Models/Study.php b/app/Models/Study.php index b32da20..c8ceb76 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -367,4 +367,13 @@ protected function casts(): array 'patient_birthdate' => 'immutable_date', ]; } + + public function isLockedBy(?User $user): bool + { + if ($user === null) { + $user = auth()->user(); + } + + return $this->locking_physician_id === $user->id; + } } diff --git a/app/Services/Workflow/Manager.php b/app/Services/Workflow/Manager.php index c548869..8fbd994 100644 --- a/app/Services/Workflow/Manager.php +++ b/app/Services/Workflow/Manager.php @@ -76,7 +76,8 @@ public function canReportEdit(): bool public function canUnlockReport(): bool { - return $this->activeStudy(fn () => $this->study->isLocked() && $this->study->locking_physician_id === $this->user->id); + return $this->activeStudy(fn () => $this->study->isLocked() + && $this->study->locking_physician_id === $this->user->id); } private function checkUserPermission(Permission $permission): bool