belongsTo(Room::class, 'room_id', 'room_id'); } public function orders() { return $this->belongsToMany(Order::class, 'order_seats', 'seat_id', 'order_id'); } public function tickets() { return $this->hasMany(Ticket::class, 'seat_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 is_reserved(int $showing_id) { $tickets = $this->tickets()->where('showing_id', $showing_id)->get(); foreach ($tickets as $ticket) { if ($ticket->order->order_status == 'pending' || $ticket->order->order_status == 'paid') { return true; } } return false; } }