cineflex/app/Models/Movie.php

43 lines
853 B
PHP
Raw Normal View History

2022-11-23 09:32:34 +01:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Movie extends Model
{
protected $table = 'movies';
protected $primaryKey = 'movie_id';
public $timestamps = false;
protected $fillable = [
'movie_name',
'movie_description',
'movie_year',
'movie_image',
'user_id', // who added the movie?
'genre_id', // which genre is the movie?
];
protected $hidden = [
'created_at',
'updated_at',
];
public static function findOrfail($id)
{
return Movie::where('movie_id', $id)->firstOrFail();
}
2022-11-23 09:32:34 +01:00
public function genre()
{
return $this->belongsTo(Genre::class, 'genre_id', 'genre_id');
2022-11-23 09:32:34 +01:00
}
public function showings()
{
return $this->hasMany(Showing::class, 'movie_id', 'movie_id');
}
}