diff --git a/app/Models/MovieAlternativeTitle.php b/app/Models/MovieAlternativeTitle.php new file mode 100644 index 0000000..e0d949b --- /dev/null +++ b/app/Models/MovieAlternativeTitle.php @@ -0,0 +1,15 @@ +getForTmdbId($item->tmdb_id); + $movie = Movie::where('tmdb_id', $item->tmdb_id)->first(); foreach ($alternativeTitles['titles'] as $alternativeTitle) { - $alternativeTitleExists = $alternativeTitleModel->where('movie_id', $movie->id) + $alternativeTitleExists = MovieAlternativeTitle::where('movie_id', $movie->id) ->where('iso', $alternativeTitle['iso_3166_1']) ->first(); if (!$alternativeTitleExists) { - $alternativeTitleModel->insert([ + MovieAlternativeTitle::create([ 'iso' => $alternativeTitle['iso_3166_1'], 'movie_id' => $movie->id, 'title' => $alternativeTitle['title'], @@ -84,7 +82,23 @@ class MovieProcessingService implements ProcessingInterface } } - $this->removeElementFromRemainingJobs($item->tmdb_id, ItemJob::JOB_ALTERNVATIVE_TITLES); + $this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_ALTERNVATIVE_TITLES); + } + + private function getCredits($item) + { + $tmdbCredits = $this->moviesApi->getCredits($item->tmdb_id); + + if (empty($tmdbCredits)) { + return; + } + + $movie = Movie::where('tmdb_id', $item->tmdb_id)->first(); + + $this->processCast($movie, $tmdbCredits['cast'] ?? []); + $this->processCrew($movie, $tmdbCredits['crew'] ?? []); + + $this->removeElementFromRemainingJobs($item->tmdb_id, ItemJob::JOB_CREDITS); } private function processMovieCollection(int $movieId, $belongsToCollection) @@ -161,4 +175,14 @@ class MovieProcessingService implements ProcessingInterface $itemToFetchJobs->remaining_jobs = $remainingJobs; $itemToFetchJobs->save(); } + + private function processCast($movie, array $castList) + { + + } + + private function processCrew($movie, array $crewList) + { + + } } diff --git a/database/migrations/2024_12_29_235519_create_movie_alternative_titles_table.php b/database/migrations/2024_12_29_235519_create_movie_alternative_titles_table.php new file mode 100644 index 0000000..758c3f0 --- /dev/null +++ b/database/migrations/2024_12_29_235519_create_movie_alternative_titles_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('iso', 5)->nullable(); + $table->string('title', 500)->nullable(); + $table->integer('movie_id')->unsigned()->nullable(); + $table->string('type', 255)->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('movie_alternative_titles'); + } +};