*/ #[\Override] protected $casts = [ 'starts_at' => 'datetime', 'ends_at' => 'datetime', 'is_active' => 'boolean', 'is_ended' => 'boolean', 'winners_announced' => 'boolean', ]; public function entries(): HasMany { return $this->hasMany(RadioContestEntry::class); } public function isActive(): bool { return $this->is_active && now()->gte($this->starts_at) && now()->lte($this->ends_at) && ! $this->is_ended; } public function entryCount(): int { return $this->entries()->count(); } public function uniqueParticipants(): int { return $this->entries()->distinct('user_id')->count('user_id'); } }