From ad35058d4afe1640f10b611dbfab79d2183a89e5 Mon Sep 17 00:00:00 2001 From: rinsvent Date: Sun, 17 May 2026 19:17:46 +0700 Subject: [PATCH] feat: add models --- app/Models/Hold.php | 46 +++++++++++++++++++++++++++++++++++++++++++++ app/Models/Slot.php | 28 +++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 app/Models/Hold.php create mode 100644 app/Models/Slot.php diff --git a/app/Models/Hold.php b/app/Models/Hold.php new file mode 100644 index 0000000..5a5364e --- /dev/null +++ b/app/Models/Hold.php @@ -0,0 +1,46 @@ + HoldStatus::class, + 'expires_at' => 'datetime', + ]; + } + + /** @return BelongsTo */ + public function slot(): BelongsTo + { + return $this->belongsTo(Slot::class); + } + + public function isExpired(): bool + { + return $this->expires_at->isPast(); + } + + public function isActiveHold(): bool + { + return $this->status === HoldStatus::Held && ! $this->isExpired(); + } +} diff --git a/app/Models/Slot.php b/app/Models/Slot.php new file mode 100644 index 0000000..6e71d0c --- /dev/null +++ b/app/Models/Slot.php @@ -0,0 +1,28 @@ + 'integer', + 'remaining' => 'integer', + ]; + } + + /** @return HasMany */ + public function holds(): HasMany + { + return $this->hasMany(Hold::class); + } +}