47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Movies\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class Movie extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'movies';
|
|
|
|
protected $fillable = [
|
|
'provider',
|
|
'provider_id',
|
|
'external_ids',
|
|
'title',
|
|
'original_title',
|
|
'description',
|
|
'poster_url',
|
|
'backdrop_url',
|
|
'rating',
|
|
'release_date',
|
|
'year',
|
|
'runtime',
|
|
];
|
|
|
|
protected $casts = [
|
|
'external_ids' => 'array',
|
|
'release_date' => 'date',
|
|
];
|
|
|
|
public function genres(): BelongsToMany { return $this->belongsToMany(Genre::class, 'movie_genre'); }
|
|
public function actors(): BelongsToMany { return $this->belongsToMany(Actor::class, 'movie_actor'); }
|
|
public function directors(): BelongsToMany { return $this->belongsToMany(Director::class, 'movie_director'); }
|
|
public function studios(): BelongsToMany { return $this->belongsToMany(Studio::class, 'movie_studio'); }
|
|
public function countries(): BelongsToMany { return $this->belongsToMany(Country::class, 'movie_country'); }
|
|
public function languages(): BelongsToMany { return $this->belongsToMany(Language::class, 'movie_language'); }
|
|
|
|
protected static function newFactory(): Factory
|
|
{
|
|
return \Database\Factories\MovieFactory::new();
|
|
}
|
|
}
|