Files
movies/app/Models/Movie.php
T

97 lines
2.5 KiB
PHP
Raw Normal View History

2024-12-30 01:51:28 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Movie extends Model
{
protected $fillable = [
'tmdb_id',
'adult',
'runtime',
'backdrop_path',
'budget',
'revenue',
'homepage',
'imdb_id',
'status',
'original_language',
'original_title',
'title',
'slug',
'overview',
'tagline',
'poster_path',
'release_date',
'vote_average',
'vote_count',
];
2025-01-26 21:36:05 +02:00
protected $casts = [
'release_date' => 'date'
];
public function director()
{
return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id')
->where('movie_cast.known_for_department', 'Directing')
;
}
2024-12-30 01:51:28 +02:00
public function collections()
{
return $this->belongsToMany(MovieCollection::class, 'movies_in_collection', 'movie_id', 'collection_id');
}
public function genres()
{
return $this->belongsToMany(Genre::class, 'movie_genres', 'movie_id', 'genre_id');
}
2024-12-30 02:28:58 +02:00
public function castList()
{
2025-01-26 21:36:05 +02:00
return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id')->withPivot('known_for_department', 'character', 'order');
2024-12-30 02:28:58 +02:00
}
public function crewList()
{
return $this->belongsToMany(Person::class, 'movie_crew', 'movie_id', 'person_id');
}
2024-12-30 02:42:07 +02:00
public function images()
{
return $this->belongsToMany(Image::class, 'movie_images', 'movie_id', 'image_id');
}
2024-12-30 02:48:39 +02:00
public function keywords()
{
2024-12-30 02:55:59 +02:00
return $this->belongsToMany(Keyword::class, 'movie_keywords', 'movie_id', 'keyword_id');
}
public function releaseDates()
{
return $this->belongsToMany(ReleaseDate::class, 'movie_release_dates', 'movie_id', 'release_date_id');
2024-12-30 02:48:39 +02:00
}
2024-12-30 03:19:01 +02:00
public function watchProviders()
{
return $this->belongsToMany(WatchProvider::class, 'movie_watch_providers', 'movie_id', 'watch_provider_id');
}
2024-12-30 18:28:50 +02:00
public function videos()
{
return $this->belongsToMany(Video::class, 'movie_videos', 'movie_id', 'video_id');
}
2025-01-26 21:36:05 +02:00
public function productionCompanies()
{
return $this->belongsToMany(ProductionCompany::class, 'movie_production_companies', 'movie_id', 'production_company_id');
}
public function productionCountries()
{
return $this->belongsToMany(ProductionCountry::class, 'movie_production_countries', 'movie_id', 'production_country_id');
}
2024-12-30 01:51:28 +02:00
}