belongsTo(Room::class, 'room_id', 'room_id'); } public function tickets() { return $this->hasMany(Ticket::class, 'seat_id', 'seat_id'); } public function linked_seat() { return $this->belongsTo(Seat::class, 'seat_linked_id', 'seat_id'); } // isReserved(int showing_id) method // Looks at showing / order / ticket if it's reserved // Returns true if it is reserved, false if it isn't public function isReserved(int $showing_id): bool { $tickets = $this->tickets->where('showing_id', $showing_id); foreach ($tickets as $ticket) { if ($ticket->showing_id == $showing_id) { return true; } } return false; } }