'date', 'end_date' => 'date', 'is_active' => 'boolean', ]; // ── Relationships ──────────────────────────────────────────── public function client(): BelongsTo { return $this->belongsTo(Client::class); } public function category(): BelongsTo { return $this->belongsTo(ClientCategory::class, 'category_id'); } // ── Scopes ─────────────────────────────────────────────────── public function scopeActive($query) { return $query->where('is_active', true) ->where('start_date', '<=', today()) ->where('end_date', '>=', today()); } // ── Helpers ────────────────────────────────────────────────── public function isCurrentlyActive(): bool { return $this->is_active && $this->start_date->lte(today()) && $this->end_date->gte(today()); } public function getDaysRemainingAttribute(): int { return (int) max(0, today()->diffInDays($this->end_date, false)); } public function getStatusLabelAttribute(): string { if (! $this->is_active) return 'Inactive'; if ($this->start_date->gt(today())) return 'Upcoming'; if ($this->end_date->lt(today())) return 'Expired'; return 'Active'; } public function getStatusColorAttribute(): string { return match ($this->statusLabel) { 'Active' => 'badge-success', 'Upcoming' => 'badge-info', 'Expired' => 'badge-neutral', default => 'badge-ghost', }; } }