megacommit
This commit is contained in:
parent
2451ab45cb
commit
34ed81516b
51 changed files with 1200 additions and 251 deletions
53
app/Models/Cinema.php
Normal file
53
app/Models/Cinema.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Cinema extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'cinemas';
|
||||
protected $primaryKey = 'cinema_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'cinema_name',
|
||||
'address_id',
|
||||
'user_id', // who created this cinema
|
||||
'cinema_open',
|
||||
'cinema_close',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function address()
|
||||
{
|
||||
return $this->belongsTo(Address::class, 'address_id', 'address_id');
|
||||
}
|
||||
|
||||
public function rooms()
|
||||
{
|
||||
return $this->hasMany(Room::class, 'cinema_id', 'cinema_id');
|
||||
}
|
||||
|
||||
public function showings()
|
||||
{
|
||||
return $this->hasManyThrough(Showing::class, Room::class, 'cinema_id', 'room_id', 'cinema_id', 'room_id');
|
||||
}
|
||||
|
||||
public function find($id)
|
||||
{
|
||||
return $this->where('cinema_id', $id)->first();
|
||||
}
|
||||
|
||||
public function users() {
|
||||
//users associated
|
||||
return $this->belongsToMany('App\Models\User', 'user_assignments', 'cinema_id', 'user_id');
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue