'boolean', 'is_private' => 'boolean', 'current_sec'=> 'integer', 'synced_at' => 'datetime', ]; public function host() { return $this->belongsTo(User::class, 'host_user_id'); } public function episode() { return $this->belongsTo(Episode::class); } public function members() { return $this->hasMany(WatchPartyMember::class, 'party_id'); } public function activeMembers() { return $this->members()->where('last_ping', '>=', now()->subSeconds(30)); } public static function generateCode(): string { do { $code = strtoupper(Str::random(6)); } while (self::where('room_code', $code)->exists()); return $code; } }