From c771981c97d32cced842e64c71e3bb82bbf92ea4 Mon Sep 17 00:00:00 2001 From: Masroor Ehsan Date: Tue, 7 Jan 2025 17:53:09 +0600 Subject: [PATCH] locking --- app/Models/Study.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/Models/Study.php b/app/Models/Study.php index 1679b06..a1e567b 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -288,6 +288,30 @@ public function registerMediaConversions(?Media $media = null): void ->nonQueued(); } + public function isLocked(): bool + { + return $this->locked_at !== null; + } + + public function lockStudy(?User $user = null): void + { + $this->update( + [ + 'locking_physician_id' => $user?->id ?? auth()->id(), + 'locked_at' => now(), + ] + ); + } + + public function unlockStudy(): void + { + $this->update( + [ + 'locked_at' => null, + ] + ); + } + public function registerMediaCollections(): void { $this->addMediaCollection(self::MEDIA_COLLECTION) @@ -318,7 +342,6 @@ public function getGenderNameAttribute(): string protected function casts(): array { return [ - 'is_locked' => 'boolean', 'is_archived' => 'boolean', 'study_status' => StudyLevelStatus::class, 'report_status' => ReportStatus::class,