'Draft', self::STATUS_ACTIVE => 'Active', self::STATUS_ARCHIVED => 'Archived', ]; protected $fillable = [ 'user_id', 'name', 'description', 'status', 'starts_at', 'ends_at', ]; protected function casts(): array { return [ 'starts_at' => 'datetime', 'ends_at' => 'datetime', ]; } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function shortLinks(): HasMany { return $this->hasMany(ShortLink::class); } public function statusLabel(): string { return self::STATUSES[$this->status] ?? ucfirst((string) $this->status); } public function isLive(): bool { if ($this->status !== self::STATUS_ACTIVE) { return false; } if ($this->starts_at && $this->starts_at->isFuture()) { return false; } if ($this->ends_at && $this->ends_at->isPast()) { return false; } return true; } public function totalClicks(): int { return (int) $this->shortLinks()->sum('clicks_total'); } public function linksCount(): int { return (int) $this->shortLinks()->count(); } }