firstOrFail(); } public function room() { return $this->belongsTo(Room::class, 'room_id', 'room_id'); } public function movie() { return $this->belongsTo(Movie::class, 'movie_id', 'movie_id'); } public function nowPlaying() { return $this->where('showing_start', '>=', now())->get(); } public function end_time() { $date = new Carbon($this->showing_start); $date->addMinutes($this->movie->movie_length); return $date; } public function tickets() { return $this->hasMany(Ticket::class, 'showing_id', 'showing_id'); } public function tickets_available() { $tickets = $this->room->seats()->count(); $tickets_sold = $this->tickets()->count(); return $tickets - $tickets_sold; } public function find($id) { return Showing::where('showing_id', $id)->first(); } public function seatMatrix() { return $this->room->seatMatrix($this->showing_id); } }