cineflex/app/Models/Room.php

46 lines
900 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Room extends Model
{
protected $table = 'rooms';
protected $primaryKey = 'room_id';
public $timestamps = false;
protected $fillable = [
'room_name',
'room_rows',
'room_columns',
'user_id', // who added the room?
'cinema_id',
];
protected $hidden = [
'created_at',
'updated_at',
];
public static function find(int $room_id)
{
return self::where('room_id', $room_id)->first();
}
public function showings()
{
return $this->hasMany(Showing::class, 'room_id', 'room_id');
}
public function seats()
{
return $this->hasMany(Seat::class, 'room_id', 'room_id');
}
public function cinema()
{
return $this->belongsTo(Cinema::class, 'cinema_id', 'cinema_id');
}
}