'date' ]; public function wasListedBy(string $listSlug, User $user) { $mediaList = MediaList::where('slug', $listSlug)->where('user_id', $user->id)->first(); if ($mediaList) { $mediaListItem = MediaListItem::where('media_list_id', $mediaList->id) ->where('item_id', $this->id) ->where('item_type', 'movie') ->first(); return !empty($mediaListItem); } return false; } public function ratingBy(User $user) { $rating = Rate::where('user_id', $user->id) ->where('item_id', $this->id) ->where('item_type', 'movie') ->first(); return $rating ? $rating->rate : null; } public function trailer() { return $this->belongsToMany(Video::class, 'movie_videos', 'movie_id', 'video_id') ->where('videos.type', 'Trailer'); } public function externalIds() { return $this->hasOne(ExternalId::class, 'entity_id', 'id')->where('entity_type', ExternalId::TYPE_MOVIE); } public function director() { return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id') ->where('movie_cast.job', 'Director') ->orWhere('movie_cast.known_for_department', 'Directing') ; } 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'); } public function castList() { return $this->belongsToMany(Person::class, 'movie_cast', 'movie_id', 'person_id')->withPivot('known_for_department', 'character', 'order'); } public function crewList() { return $this->belongsToMany(Person::class, 'movie_crew', 'movie_id', 'person_id')->withPivot('department', 'job'); } public function images() { return $this->belongsToMany(Image::class, 'movie_images', 'movie_id', 'image_id'); } public function keywords() { 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'); } public function watchProviders() { return $this->belongsToMany(WatchProvider::class, 'movie_watch_providers', 'movie_id', 'watch_provider_id'); } public function videos() { return $this->belongsToMany(Video::class, 'movie_videos', 'movie_id', 'video_id'); } 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'); } public function similar() { return $this->belongsToMany(Movie::class, 'movie_similars', 'movie_id', 'similar_movie_id'); } public function recommendations() { return $this->belongsToMany(Movie::class, 'movie_recommendations', 'movie_id', 'recommended_movie_id'); } }