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); + } +}