fix+add: seats + seat-chooser

This commit is contained in:
Didier Slof 2023-01-01 20:13:11 +01:00
parent 2c6745e812
commit b0cc5b5278
Signed by: didier
GPG key ID: 01E71F18AA4398E5
31 changed files with 808 additions and 115 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
@ -45,4 +46,29 @@ class Showing extends Model
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);
}
}