From ae33c74f2b887ebef027eeb5696292d1f1dcdaa9 Mon Sep 17 00:00:00 2001 From: Roardom Date: Mon, 17 Mar 2025 19:35:20 +0000 Subject: [PATCH] refactor: prefix tmdb metadata models with `tmdb` Will help for when there exists other metadata sources available (such as already done for igdb) Step 4 in cleaner meta fetching code. --- .../Commands/AutoCacheRandomMediaIds.php | 8 +- .../Commands/AutoSyncPeopleToMeilisearch.php | 4 +- app/Console/Commands/DemoSeed.php | 4 +- app/DTO/TorrentSearchFiltersDTO.php | 54 +++--- app/Helpers/Helpers.php | 2 +- app/Helpers/TorrentHelper.php | 14 +- .../Controllers/API/QuickSearchController.php | 12 +- .../Controllers/API/TorrentController.php | 30 ++-- .../Controllers/MediaHub/HomeController.php | 28 +-- ...oller.php => TmdbCollectionController.php} | 6 +- ...ntroller.php => TmdbCompanyController.php} | 2 +- ...Controller.php => TmdbGenreController.php} | 6 +- ...ntroller.php => TmdbNetworkController.php} | 2 +- ...ontroller.php => TmdbPersonController.php} | 6 +- app/Http/Controllers/PlaylistController.php | 8 +- app/Http/Controllers/RequestController.php | 32 ++-- app/Http/Controllers/RssController.php | 6 +- .../Controllers/SimilarTorrentController.php | 20 +-- app/Http/Controllers/Staff/RssController.php | 6 +- app/Http/Controllers/TorrentController.php | 40 ++--- app/Http/Controllers/User/WishController.php | 16 +- .../Controllers/YearlyOverviewController.php | 32 ++-- app/Http/Livewire/Comment.php | 6 +- app/Http/Livewire/Comments.php | 6 +- app/Http/Livewire/MissingMediaSearch.php | 6 +- app/Http/Livewire/RandomMedia.php | 16 +- app/Http/Livewire/SimilarTorrent.php | 22 +-- ...ionSearch.php => TmdbCollectionSearch.php} | 10 +- ...ompanySearch.php => TmdbCompanySearch.php} | 10 +- ...etworkSearch.php => TmdbNetworkSearch.php} | 10 +- ...{PersonCredit.php => TmdbPersonCredit.php} | 18 +- ...{PersonSearch.php => TmdbPersonSearch.php} | 14 +- .../{TvSearch.php => TmdbTvSearch.php} | 10 +- app/Http/Livewire/Top10.php | 12 +- app/Http/Livewire/TorrentRequestSearch.php | 18 +- app/Http/Livewire/TorrentSearch.php | 95 +++++----- app/Http/Requests/StoreTorrentRequest.php | 16 +- .../Requests/StoreTorrentRequestRequest.php | 18 +- app/Http/Requests/StoreWishRequest.php | 12 +- app/Http/Requests/UpdateTorrentRequest.php | 4 +- .../Requests/UpdateTorrentRequestRequest.php | 4 +- app/Http/Resources/TorrentResource.php | 2 +- app/Jobs/ProcessMovieJob.php | 34 ++-- app/Jobs/ProcessTvJob.php | 42 ++--- app/Models/GuestStar.php | 6 +- app/Models/Occupation.php | 8 +- .../{Collection.php => TmdbCollection.php} | 10 +- app/Models/{Company.php => TmdbCompany.php} | 18 +- app/Models/{Credit.php => TmdbCredit.php} | 24 +-- app/Models/{Episode.php => TmdbEpisode.php} | 18 +- app/Models/{Genre.php => TmdbGenre.php} | 14 +- app/Models/{Movie.php => TmdbMovie.php} | 38 ++-- app/Models/{Network.php => TmdbNetwork.php} | 16 +- app/Models/{Person.php => TmdbPerson.php} | 94 +++++----- ...ommendation.php => TmdbRecommendation.php} | 22 +-- app/Models/{Season.php => TmdbSeason.php} | 18 +- app/Models/{Tv.php => TmdbTv.php} | 44 ++--- app/Models/Torrent.php | 166 +++++++++--------- app/Models/TorrentRequest.php | 20 +-- app/Models/Wish.php | 8 +- app/Notifications/NewCommentTag.php | 8 +- app/Services/Tmdb/Client/Movie.php | 42 ++--- app/Services/Tmdb/Client/Season.php | 12 +- app/Services/Tmdb/Client/TV.php | 52 +++--- app/Traits/TorrentMeta.php | 20 +-- config/scout.php | 46 ++--- database/factories/RecommendationFactory.php | 49 ------ ...nFactory.php => TmdbCollectionFactory.php} | 8 +- ...workFactory.php => TmdbCompanyFactory.php} | 12 +- ...reditFactory.php => TmdbCreditFactory.php} | 26 +-- ...sodeFactory.php => TmdbEpisodeFactory.php} | 14 +- ...{GenreFactory.php => TmdbGenreFactory.php} | 8 +- ...{MovieFactory.php => TmdbMovieFactory.php} | 8 +- ...panyFactory.php => TmdbNetworkFactory.php} | 12 +- ...ersonFactory.php => TmdbPersonFactory.php} | 8 +- .../factories/TmdbRecommendationFactory.php | 49 ++++++ ...easonFactory.php => TmdbSeasonFactory.php} | 12 +- .../{TvFactory.php => TmdbTvFactory.php} | 8 +- database/factories/TorrentFactory.php | 4 +- database/factories/TorrentRequestFactory.php | 4 +- ...748_add_tmdb_prefix_to_metadata_tables.php | 132 ++++++++++++++ phpstan-baseline.neon | 8 +- phpstan.neon | 2 +- resources/views/blocks/featured.blade.php | 8 +- .../views/components/torrent/card.blade.php | 2 +- .../views/components/torrent/row.blade.php | 2 +- ...e.php => tmdb-collection-search.blade.php} | 0 ...lade.php => tmdb-company-search.blade.php} | 0 ...lade.php => tmdb-network-search.blade.php} | 0 ...blade.php => tmdb-person-credit.blade.php} | 0 ...blade.php => tmdb-person-search.blade.php} | 0 ...rch.blade.php => tmdb-tv-search.blade.php} | 0 resources/views/livewire/top10.blade.php | 12 +- .../views/livewire/torrent-search.blade.php | 4 +- .../views/mediahub/collection/index.blade.php | 2 +- .../views/mediahub/company/index.blade.php | 2 +- .../views/mediahub/network/index.blade.php | 2 +- .../views/mediahub/person/index.blade.php | 2 +- .../views/mediahub/person/show.blade.php | 2 +- resources/views/requests/create.blade.php | 20 +-- resources/views/requests/edit.blade.php | 20 +-- resources/views/requests/show.blade.php | 4 +- resources/views/rss/show.blade.php | 10 +- .../stats/yearly_overviews/show.blade.php | 8 +- resources/views/torrent/create.blade.php | 12 +- resources/views/torrent/edit.blade.php | 24 +-- .../torrent/partials/game_meta.blade.php | 8 +- .../torrent/partials/movie_meta.blade.php | 8 +- .../views/torrent/partials/no_meta.blade.php | 6 +- .../views/torrent/partials/tv_meta.blade.php | 8 +- resources/views/torrent/show.blade.php | 4 +- resources/views/user/wish/index.blade.php | 12 +- routes/web.php | 14 +- ...t.php => TmdbCollectionControllerTest.php} | 8 +- ...Test.php => TmdbCompanyControllerTest.php} | 4 +- ...erTest.php => TmdbGenreControllerTest.php} | 0 ...Test.php => TmdbNetworkControllerTest.php} | 4 +- ...rTest.php => TmdbPersonControllerTest.php} | 8 +- .../Controllers/RequestControllerTest.php | 12 +- .../Http/Controllers/RssControllerTest.php | 8 +- .../SimilarTorrentControllerTest.php | 12 +- .../Controllers/Staff/RssControllerTest.php | 8 +- .../Controllers/TorrentControllerTest.php | 12 +- .../NewUploadNotificationTest.php | 16 +- tests/Old/TorrentControllerTest.php | 4 +- .../StoreTorrentRequestRequestTest.php | 14 +- .../Http/Requests/StoreTorrentRequestTest.php | 12 +- 127 files changed, 1116 insertions(+), 993 deletions(-) rename app/Http/Controllers/MediaHub/{CollectionController.php => TmdbCollectionController.php} (81%) rename app/Http/Controllers/MediaHub/{CompanyController.php => TmdbCompanyController.php} (93%) rename app/Http/Controllers/MediaHub/{GenreController.php => TmdbGenreController.php} (82%) rename app/Http/Controllers/MediaHub/{NetworkController.php => TmdbNetworkController.php} (93%) rename app/Http/Controllers/MediaHub/{PersonController.php => TmdbPersonController.php} (87%) rename app/Http/Livewire/{CollectionSearch.php => TmdbCollectionSearch.php} (88%) rename app/Http/Livewire/{CompanySearch.php => TmdbCompanySearch.php} (91%) rename app/Http/Livewire/{NetworkSearch.php => TmdbNetworkSearch.php} (90%) rename app/Http/Livewire/{PersonCredit.php => TmdbPersonCredit.php} (97%) rename app/Http/Livewire/{PersonSearch.php => TmdbPersonSearch.php} (87%) rename app/Http/Livewire/{TvSearch.php => TmdbTvSearch.php} (89%) rename app/Models/{Collection.php => TmdbCollection.php} (86%) rename app/Models/{Company.php => TmdbCompany.php} (72%) rename app/Models/{Credit.php => TmdbCredit.php} (76%) rename app/Models/{Episode.php => TmdbEpisode.php} (80%) rename app/Models/{Genre.php => TmdbGenre.php} (79%) rename app/Models/{Movie.php => TmdbMovie.php} (81%) rename app/Models/{Network.php => TmdbNetwork.php} (76%) rename app/Models/{Person.php => TmdbPerson.php} (79%) rename app/Models/{Recommendation.php => TmdbRecommendation.php} (71%) rename app/Models/{Season.php => TmdbSeason.php} (75%) rename app/Models/{Tv.php => TmdbTv.php} (80%) delete mode 100644 database/factories/RecommendationFactory.php rename database/factories/{CollectionFactory.php => TmdbCollectionFactory.php} (87%) rename database/factories/{NetworkFactory.php => TmdbCompanyFactory.php} (87%) rename database/factories/{CreditFactory.php => TmdbCreditFactory.php} (57%) rename database/factories/{EpisodeFactory.php => TmdbEpisodeFactory.php} (81%) rename database/factories/{GenreFactory.php => TmdbGenreFactory.php} (84%) rename database/factories/{MovieFactory.php => TmdbMovieFactory.php} (93%) rename database/factories/{CompanyFactory.php => TmdbNetworkFactory.php} (87%) rename database/factories/{PersonFactory.php => TmdbPersonFactory.php} (91%) create mode 100644 database/factories/TmdbRecommendationFactory.php rename database/factories/{SeasonFactory.php => TmdbSeasonFactory.php} (83%) rename database/factories/{TvFactory.php => TmdbTvFactory.php} (95%) create mode 100644 database/migrations/2025_03_17_122748_add_tmdb_prefix_to_metadata_tables.php rename resources/views/livewire/{collection-search.blade.php => tmdb-collection-search.blade.php} (100%) rename resources/views/livewire/{company-search.blade.php => tmdb-company-search.blade.php} (100%) rename resources/views/livewire/{network-search.blade.php => tmdb-network-search.blade.php} (100%) rename resources/views/livewire/{person-credit.blade.php => tmdb-person-credit.blade.php} (100%) rename resources/views/livewire/{person-search.blade.php => tmdb-person-search.blade.php} (100%) rename resources/views/livewire/{tv-search.blade.php => tmdb-tv-search.blade.php} (100%) rename tests/Feature/Http/Controllers/MediaHub/{CollectionControllerTest.php => TmdbCollectionControllerTest.php} (84%) rename tests/Feature/Http/Controllers/MediaHub/{CompanyControllerTest.php => TmdbCompanyControllerTest.php} (87%) rename tests/Feature/Http/Controllers/MediaHub/{GenreControllerTest.php => TmdbGenreControllerTest.php} (100%) rename tests/Feature/Http/Controllers/MediaHub/{NetworkControllerTest.php => TmdbNetworkControllerTest.php} (87%) rename tests/Feature/Http/Controllers/MediaHub/{PersonControllerTest.php => TmdbPersonControllerTest.php} (85%) diff --git a/app/Console/Commands/AutoCacheRandomMediaIds.php b/app/Console/Commands/AutoCacheRandomMediaIds.php index 65cfa2117..0bfb842e0 100644 --- a/app/Console/Commands/AutoCacheRandomMediaIds.php +++ b/app/Console/Commands/AutoCacheRandomMediaIds.php @@ -16,8 +16,8 @@ declare(strict_types=1); namespace App\Console\Commands; -use App\Models\Movie; -use App\Models\Tv; +use App\Models\TmdbMovie; +use App\Models\TmdbTv; use Illuminate\Console\Command; use Exception; use Illuminate\Support\Facades\Redis; @@ -46,13 +46,13 @@ class AutoCacheRandomMediaIds extends Command */ final public function handle(): void { - $movieIds = Movie::query() + $movieIds = TmdbMovie::query() ->select('id') ->whereHas('torrents') ->whereNotNull('backdrop') ->pluck('id'); - $tvIds = Tv::query() + $tvIds = TmdbTv::query() ->select('id') ->whereHas('torrents') ->whereNotNull('backdrop') diff --git a/app/Console/Commands/AutoSyncPeopleToMeilisearch.php b/app/Console/Commands/AutoSyncPeopleToMeilisearch.php index ac0e92cd0..47b4a6dff 100644 --- a/app/Console/Commands/AutoSyncPeopleToMeilisearch.php +++ b/app/Console/Commands/AutoSyncPeopleToMeilisearch.php @@ -16,7 +16,7 @@ declare(strict_types=1); namespace App\Console\Commands; -use App\Models\Person; +use App\Models\TmdbPerson; use Exception; use Illuminate\Console\Command; use Meilisearch\Client; @@ -49,7 +49,7 @@ class AutoSyncPeopleToMeilisearch extends Command $client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key')); $index = $client->index(config('scout.prefix').'people'); - $people = Person::all(['id', 'name', 'birthday', 'still']); + $people = TmdbPerson::all(['id', 'name', 'birthday', 'still']); $documents = $people->map(fn ($person) => [ 'id' => $person->id, diff --git a/app/Console/Commands/DemoSeed.php b/app/Console/Commands/DemoSeed.php index 6df149247..a0e07ac40 100644 --- a/app/Console/Commands/DemoSeed.php +++ b/app/Console/Commands/DemoSeed.php @@ -80,7 +80,7 @@ class DemoSeed extends Command Torrent::factory()->create([ 'user_id' => $uid, - 'movie_id' => $id, + 'tmdb_movie_id' => $id, 'name' => $movie['title'], 'description' => $movie['overview'], 'category_id' => 1, @@ -275,7 +275,7 @@ Menu Torrent::factory()->create([ 'user_id' => $uid, - 'tv_id' => $id, + 'tmdb_tv_id' => $id, 'name' => $tv['name'], 'description' => $tv['overview'], 'category_id' => 2, diff --git a/app/DTO/TorrentSearchFiltersDTO.php b/app/DTO/TorrentSearchFiltersDTO.php index b8727aab2..b25e96107 100644 --- a/app/DTO/TorrentSearchFiltersDTO.php +++ b/app/DTO/TorrentSearchFiltersDTO.php @@ -200,12 +200,12 @@ readonly class TorrentSearchFiltersDTO ->where( fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIn('movie_id', DB::table('genre_movie')->select('movie_id')->whereIn('genre_id', $this->genreIds)) + ->whereIn('tmdb_movie_id', DB::table('tmdb_genre_tmdb_movie')->select('tmdb_movie_id')->whereIn('tmdb_genre_id', $this->genreIds)) ) ->orWhere( fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIn('tv_id', DB::table('genre_tv')->select('tv_id')->whereIn('genre_id', $this->genreIds)) + ->whereIn('tmdb_tv_id', DB::table('tmdb_genre_tmdb_tv')->select('tmdb_tv_id')->whereIn('tmdb_genre_id', $this->genreIds)) ) ) ) @@ -232,8 +232,8 @@ readonly class TorrentSearchFiltersDTO fn ($query) => $query ->where( fn ($query) => $query - ->where('movie_id', '=', $this->tmdbId) - ->orWhere('tv_id', '=', $this->tmdbId) + ->where('tmdb_movie_id', '=', $this->tmdbId) + ->orWhere('tmdb_tv_id', '=', $this->tmdbId) ) ) ->when($this->imdbId !== null, fn ($query) => $query->where('imdb', '=', $this->imdbId)) @@ -267,7 +267,7 @@ readonly class TorrentSearchFiltersDTO $this->collectionId !== null, fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIn('movie_id', DB::table('collection_movie')->select('movie_id')->where('collection_id', '=', $this->collectionId)) + ->whereIn('tmdb_movie_id', DB::table('tmdb_collection_tmdb_movie')->select('tmdb_movie_id')->where('tmdb_collection_id', '=', $this->collectionId)) ) ->when( $this->companyId !== null, @@ -277,12 +277,12 @@ readonly class TorrentSearchFiltersDTO ->where( fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIn('movie_id', DB::table('company_movie')->select('movie_id')->where('company_id', '=', $this->companyId)) + ->whereIn('tmdb_movie_id', DB::table('tmdb_company_tmdb_movie')->select('tmdb_movie_id')->where('tmdb_company_id', '=', $this->companyId)) ) ->orWhere( fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIn('tv_id', DB::table('company_tv')->select('tv_id')->where('company_id', '=', $this->companyId)) + ->whereIn('tmdb_tv_id', DB::table('tmdb_company_tmdb_tv')->select('tmdb_tv_id')->where('tmdb_company_id', '=', $this->companyId)) ) ) ) @@ -290,7 +290,7 @@ readonly class TorrentSearchFiltersDTO $this->networkId !== null, fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIn('tv_id', DB::table('network_tv')->select('tv_id')->where('network_id', '=', $this->networkId)) + ->whereIn('tmdb_tv_id', DB::table('tmdb_network_tmdb_tv')->select('tmdb_tv_id')->where('tmdb_network_id', '=', $this->networkId)) ) ->when( $this->primaryLanguageNames !== [], @@ -369,12 +369,12 @@ readonly class TorrentSearchFiltersDTO ->where( fn ($query) => $query ->whereRelation('movie_meta', '=', true) - ->whereIn('movie_id', Wish::select('movie_id')->where('user_id', '=', $this->user->id)) + ->whereIn('tmdb_movie_id', Wish::select('tmdb_movie_id')->where('user_id', '=', $this->user->id)) ) ->orWhere( fn ($query) => $query ->whereRelation('tv_meta', '=', true) - ->whereIn('tv_id', Wish::select('tv_id')->where('user_id', '=', $this->user->id)) + ->whereIn('tmdb_tv_id', Wish::select('tmdb_tv_id')->where('user_id', '=', $this->user->id)) ) ) ) @@ -460,15 +460,15 @@ readonly class TorrentSearchFiltersDTO if ($this->startYear !== null) { $filters[] = [ - 'movie.year >= '.$this->startYear, - 'tv.year >= '.$this->startYear, + 'tmdb_movie.year >= '.$this->startYear, + 'tmdb_tv.year >= '.$this->startYear, ]; } if ($this->endYear !== null) { $filters[] = [ - 'movie.year <= '.$this->endYear, - 'tv.year <= '.$this->endYear, + 'tmdb_movie.year <= '.$this->endYear, + 'tmdb_tv.year <= '.$this->endYear, ]; } @@ -502,8 +502,8 @@ readonly class TorrentSearchFiltersDTO if ($this->genreIds !== []) { $filters[] = [ - 'movie.genres.id IN '.json_encode(array_map('intval', $this->genreIds)), - 'tv.genres.id IN '.json_encode(array_map('intval', $this->genreIds)), + 'tmdb_movie.genres.id IN '.json_encode(array_map('intval', $this->genreIds)), + 'tmdb_tv.genres.id IN '.json_encode(array_map('intval', $this->genreIds)), ]; } @@ -530,13 +530,13 @@ readonly class TorrentSearchFiltersDTO } if ($this->adult !== null) { - $filters[] = 'movie.adult = '.($this->adult ? 'true' : 'false'); + $filters[] = 'tmdb_movie.adult = '.($this->adult ? 'true' : 'false'); } if ($this->tmdbId !== null) { $filters[] = [ - 'movie_id = '.$this->tmdbId, - 'tv_id = '.$this->tmdbId, + 'tmdb_movie_id = '.$this->tmdbId, + 'tmdb_tv_id = '.$this->tmdbId, ]; } @@ -557,24 +557,24 @@ readonly class TorrentSearchFiltersDTO } if ($this->collectionId !== null) { - $filters[] = 'movie.collection.id = '.$this->collectionId; + $filters[] = 'tmdb_movie.collection.id = '.$this->collectionId; } if ($this->companyId !== null) { $filters[] = [ - 'movie.companies.id = '.$this->companyId, - 'tv.companies.id = '.$this->companyId, + 'tmdb_movie.companies.id = '.$this->companyId, + 'tmdb_tv.companies.id = '.$this->companyId, ]; } if ($this->networkId !== null) { - $filters[] = 'tv.networks.id = '.$this->networkId; + $filters[] = 'tmdb_tv.networks.id = '.$this->networkId; } if ($this->primaryLanguageNames !== []) { $filters[] = [ - 'movie.original_language IN '.json_encode(array_map('strval', $this->primaryLanguageNames)), - 'tv.original_language IN '.json_encode(array_map('strval', $this->primaryLanguageNames)), + 'tmdb_movie.original_language IN '.json_encode(array_map('strval', $this->primaryLanguageNames)), + 'tmdb_tv.original_language IN '.json_encode(array_map('strval', $this->primaryLanguageNames)), ]; } @@ -650,8 +650,8 @@ readonly class TorrentSearchFiltersDTO if ($this->userWished) { $filters[] = [ - 'movie.wishes.user_id = '.$this->user->id, - 'tv.wishes.user_id = '.$this->user->id, + 'tmdb_movie.wishes.user_id = '.$this->user->id, + 'tmdb_tv.wishes.user_id = '.$this->user->id, ]; } diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php index 8d6c0ba51..35cb71270 100644 --- a/app/Helpers/Helpers.php +++ b/app/Helpers/Helpers.php @@ -75,7 +75,7 @@ if (!\function_exists('href_playlist')) { } if (!\function_exists('href_collection')) { - function href_collection(App\Models\Collection $collection): string + function href_collection(App\Models\TmdbCollection $collection): string { $appurl = appurl(); diff --git a/app/Helpers/TorrentHelper.php b/app/Helpers/TorrentHelper.php index 9e5d32f5c..c77b04a54 100644 --- a/app/Helpers/TorrentHelper.php +++ b/app/Helpers/TorrentHelper.php @@ -31,10 +31,10 @@ use App\Achievements\UserMadeUpload; use App\Bots\IRCAnnounceBot; use App\Enums\ModerationStatus; use App\Models\AutomaticTorrentFreeleech; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Scopes\ApprovedScope; use App\Models\Torrent; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\User; use App\Notifications\NewUpload; use App\Notifications\NewWishListNotice; @@ -79,7 +79,7 @@ class TorrentHelper switch (true) { case $torrent->category->movie_meta: User::query() - ->whereRelation('wishes', 'movie_id', '=', $torrent->movie_id) + ->whereRelation('wishes', 'tmdb_movie_id', '=', $torrent->tmdb_movie_id) ->get() ->each ->notify(new NewWishListNotice($torrent)); @@ -87,7 +87,7 @@ class TorrentHelper break; case $torrent->category->tv_meta: User::query() - ->whereRelation('wishes', 'tv_id', '=', $torrent->tv_id) + ->whereRelation('wishes', 'tmdb_tv_id', '=', $torrent->tmdb_tv_id) ->get() ->each ->notify(new NewWishListNotice($torrent)); @@ -126,10 +126,10 @@ class TorrentHelper $meta = null; $category = $torrent->category; - if ($torrent->movie_id > 0 || $torrent->tv_id > 0) { + if ($torrent->tmdb_movie_id > 0 || $torrent->tmdb_tv_id > 0) { $meta = match (true) { - $category->tv_meta => Tv::find($torrent->tv_id), - $category->movie_meta => Movie::find($torrent->movie_id), + $category->tv_meta => TmdbTv::find($torrent->tmdb_tv_id), + $category->movie_meta => TmdbMovie::find($torrent->tmdb_movie_id), default => null, }; } diff --git a/app/Http/Controllers/API/QuickSearchController.php b/app/Http/Controllers/API/QuickSearchController.php index de6e0df80..b42feded9 100644 --- a/app/Http/Controllers/API/QuickSearchController.php +++ b/app/Http/Controllers/API/QuickSearchController.php @@ -37,8 +37,8 @@ class QuickSearchController extends Controller 'category.tv_meta = true', ], [ - 'movie.name EXISTS', - 'tv.name EXISTS', + 'tmdb_movie.name EXISTS', + 'tmdb_tv.name EXISTS', ] ]; @@ -47,8 +47,8 @@ class QuickSearchController extends Controller if (preg_match('/^(\d+)$/', $query, $matches)) { $filters[] = [ - 'movie_id = '.$matches[1], - 'tv_id = '.$matches[1], + 'tmdb_movie_id = '.$matches[1], + 'tmdb_tv_id = '.$matches[1], ]; $searchById = true; } @@ -85,14 +85,14 @@ class QuickSearchController extends Controller // Process the hits from the multiSearchResults foreach ($multiSearchResults['hits'] as $hit) { if ($hit['_federation']['indexUid'] === config('scout.prefix').'torrents') { - $type = $hit['category']['movie_meta'] === true ? 'movie' : 'tv'; + $type = $hit['category']['movie_meta'] === true ? 'tmdb_movie' : 'tmdb_tv'; $results[] = [ 'id' => $hit['id'], 'name' => $hit[$type]['name'], 'year' => $hit[$type]['year'], 'image' => $hit[$type]['poster'] ? tmdb_image('poster_small', $hit[$type]['poster']) : ($hit['name'][0] ?? '').($hit['name'][1] ?? ''), - 'url' => route('torrents.similar', ['category_id' => $hit['category']['id'], 'tmdb' => $hit['tmdb']]), + 'url' => route('torrents.similar', ['category_id' => $hit['category']['id'], 'tmdb' => $hit["{$type}_id"]]), 'type' => $hit['category']['name'], ]; } elseif ($hit['_federation']['indexUid'] === config('scout.prefix').'people') { diff --git a/app/Http/Controllers/API/TorrentController.php b/app/Http/Controllers/API/TorrentController.php index a6a097e92..fdf78b3a0 100644 --- a/app/Http/Controllers/API/TorrentController.php +++ b/app/Http/Controllers/API/TorrentController.php @@ -26,10 +26,10 @@ use App\Models\Category; use App\Models\FeaturedTorrent; use App\Models\IgdbGame; use App\Models\Keyword; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Torrent; use App\Models\TorrentFile; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\User; use App\Repositories\ChatRepository; use App\Services\Igdb\IgdbScraper; @@ -161,8 +161,8 @@ class TorrentController extends BaseController $torrent->user_id = $user->id; $torrent->imdb = $request->input('imdb'); $torrent->tvdb = $request->input('tvdb'); - $torrent->movie_id = $category->movie_meta ? $request->integer('tmdb') : 0; - $torrent->tv_id = $category->tv_meta ? $request->integer('tmdb') : 0; + $torrent->tmdb_movie_id = $category->movie_meta ? $request->integer('tmdb') : 0; + $torrent->tmdb_tv_id = $category->tv_meta ? $request->integer('tmdb') : 0; $torrent->mal = $request->input('mal'); $torrent->igdb = $request->integer('igdb'); $torrent->season_number = $request->input('season_number'); @@ -268,7 +268,7 @@ class TorrentController extends BaseController Rule::in([0]), ]), ], - 'movie_id' => [ + 'tmdb_movie_id' => [ Rule::when($category->movie_meta, [ 'required', 'decimal:0', @@ -278,7 +278,7 @@ class TorrentController extends BaseController Rule::in([0]), ]), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ Rule::when($category->tv_meta, [ 'required', 'decimal:0', @@ -394,10 +394,10 @@ class TorrentController extends BaseController // Metadata updates come after tracker updates in case TMDB or IGDB is offline match (true) { - $category->tv_meta && $torrent->tv_id > 0 => new TMDBScraper()->tv($torrent->tv_id), - $category->movie_meta && $torrent->movie_id > 0 => new TMDBScraper()->movie($torrent->movie_id), - $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), - default => null, + $category->tv_meta && $torrent->tmdb_tv_id > 0 => new TMDBScraper()->tv($torrent->tmdb_tv_id), + $category->movie_meta && $torrent->tmdb_movie_id > 0 => new TMDBScraper()->movie($torrent->tmdb_movie_id), + $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), + default => null, }; // Torrent Keywords System @@ -504,12 +504,12 @@ class TorrentController extends BaseController $torrent->setAttribute('meta', null); - if ($torrent->category->tv_meta && $torrent->tv_id) { - $torrent->setAttribute('meta', Tv::with(['genres'])->find($torrent->tv_id)); + if ($torrent->category->tv_meta && $torrent->tmdb_tv_id) { + $torrent->setAttribute('meta', TmdbTv::with(['genres'])->find($torrent->tmdb_tv_id)); } - if ($torrent->category->movie_meta && $torrent->movie_id) { - $torrent->setAttribute('meta', Movie::with(['genres'])->find($torrent->movie_id)); + if ($torrent->category->movie_meta && $torrent->tmdb_movie_id) { + $torrent->setAttribute('meta', TmdbMovie::with(['genres'])->find($torrent->tmdb_movie_id)); } if ($torrent->category->game_meta && $torrent->igdb) { @@ -678,7 +678,7 @@ class TorrentController extends BaseController 'seeders' => $hit['seeders'], 'leechers' => $hit['leechers'], 'times_completed' => $hit['times_completed'], - 'tmdb_id' => $hit['movie_id'] ?: $hit['tv_id'] ?: 0, + 'tmdb_id' => $hit['tmdb_movie_id'] ?: $hit['tmdb_tv_id'] ?: 0, 'imdb_id' => $hit['imdb'], 'tvdb_id' => $hit['tvdb'], 'mal_id' => $hit['mal'], diff --git a/app/Http/Controllers/MediaHub/HomeController.php b/app/Http/Controllers/MediaHub/HomeController.php index 09511b809..c63e39a61 100644 --- a/app/Http/Controllers/MediaHub/HomeController.php +++ b/app/Http/Controllers/MediaHub/HomeController.php @@ -18,13 +18,13 @@ namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; use App\Models\Category; -use App\Models\Collection; -use App\Models\Company; -use App\Models\Genre; -use App\Models\Movie; -use App\Models\Network; -use App\Models\Person; -use App\Models\Tv; +use App\Models\TmdbCollection; +use App\Models\TmdbCompany; +use App\Models\TmdbGenre; +use App\Models\TmdbMovie; +use App\Models\TmdbNetwork; +use App\Models\TmdbPerson; +use App\Models\TmdbTv; class HomeController extends Controller { @@ -34,15 +34,15 @@ class HomeController extends Controller public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('mediahub.index', [ - 'tv' => Tv::count(), - 'movies' => Movie::count(), + 'tv' => TmdbTv::count(), + 'movies' => TmdbMovie::count(), 'movieCategoryIds' => Category::where('movie_meta', '=', 1)->pluck('id')->toArray(), 'tvCategoryIds' => Category::where('tv_meta', '=', 1)->pluck('id')->toArray(), - 'collections' => Collection::count(), - 'persons' => Person::whereNotNull('still')->count(), - 'genres' => Genre::count(), - 'networks' => Network::count(), - 'companies' => Company::count(), + 'collections' => TmdbCollection::count(), + 'persons' => TmdbPerson::whereNotNull('still')->count(), + 'genres' => TmdbGenre::count(), + 'networks' => TmdbNetwork::count(), + 'companies' => TmdbCompany::count(), ]); } } diff --git a/app/Http/Controllers/MediaHub/CollectionController.php b/app/Http/Controllers/MediaHub/TmdbCollectionController.php similarity index 81% rename from app/Http/Controllers/MediaHub/CollectionController.php rename to app/Http/Controllers/MediaHub/TmdbCollectionController.php index da5909525..cbadb46e5 100644 --- a/app/Http/Controllers/MediaHub/CollectionController.php +++ b/app/Http/Controllers/MediaHub/TmdbCollectionController.php @@ -17,9 +17,9 @@ declare(strict_types=1); namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; -use App\Models\Collection; +use App\Models\TmdbCollection; -class CollectionController extends Controller +class TmdbCollectionController extends Controller { /** * Display a listing of the resource. @@ -35,7 +35,7 @@ class CollectionController extends Controller public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('mediahub.collection.show', [ - 'collection' => Collection::with(['movie' => fn ($query) => $query->has('torrents'), 'comments'])->findOrFail($id), + 'collection' => TmdbCollection::with(['movie' => fn ($query) => $query->has('torrents'), 'comments'])->findOrFail($id), ]); } } diff --git a/app/Http/Controllers/MediaHub/CompanyController.php b/app/Http/Controllers/MediaHub/TmdbCompanyController.php similarity index 93% rename from app/Http/Controllers/MediaHub/CompanyController.php rename to app/Http/Controllers/MediaHub/TmdbCompanyController.php index c1533e00b..eb44f02d8 100644 --- a/app/Http/Controllers/MediaHub/CompanyController.php +++ b/app/Http/Controllers/MediaHub/TmdbCompanyController.php @@ -18,7 +18,7 @@ namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; -class CompanyController extends Controller +class TmdbCompanyController extends Controller { /** * Display All Companies. diff --git a/app/Http/Controllers/MediaHub/GenreController.php b/app/Http/Controllers/MediaHub/TmdbGenreController.php similarity index 82% rename from app/Http/Controllers/MediaHub/GenreController.php rename to app/Http/Controllers/MediaHub/TmdbGenreController.php index 9bc6988d1..f5d285393 100644 --- a/app/Http/Controllers/MediaHub/GenreController.php +++ b/app/Http/Controllers/MediaHub/TmdbGenreController.php @@ -17,9 +17,9 @@ declare(strict_types=1); namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; -use App\Models\Genre; +use App\Models\TmdbGenre; -class GenreController extends Controller +class TmdbGenreController extends Controller { /** * Display All Genres. @@ -27,7 +27,7 @@ class GenreController extends Controller public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('mediahub.genre.index', [ - 'genres' => Genre::withCount(['tv', 'movie'])->orderBy('name')->get(), + 'genres' => TmdbGenre::withCount(['tv', 'movie'])->orderBy('name')->get(), ]); } } diff --git a/app/Http/Controllers/MediaHub/NetworkController.php b/app/Http/Controllers/MediaHub/TmdbNetworkController.php similarity index 93% rename from app/Http/Controllers/MediaHub/NetworkController.php rename to app/Http/Controllers/MediaHub/TmdbNetworkController.php index bdaebb028..b339ed81d 100644 --- a/app/Http/Controllers/MediaHub/NetworkController.php +++ b/app/Http/Controllers/MediaHub/TmdbNetworkController.php @@ -18,7 +18,7 @@ namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; -class NetworkController extends Controller +class TmdbNetworkController extends Controller { /** * Display All Networks. diff --git a/app/Http/Controllers/MediaHub/PersonController.php b/app/Http/Controllers/MediaHub/TmdbPersonController.php similarity index 87% rename from app/Http/Controllers/MediaHub/PersonController.php rename to app/Http/Controllers/MediaHub/TmdbPersonController.php index 11afcf17e..399b98222 100644 --- a/app/Http/Controllers/MediaHub/PersonController.php +++ b/app/Http/Controllers/MediaHub/TmdbPersonController.php @@ -17,9 +17,9 @@ declare(strict_types=1); namespace App\Http\Controllers\MediaHub; use App\Http\Controllers\Controller; -use App\Models\Person; +use App\Models\TmdbPerson; -class PersonController extends Controller +class TmdbPersonController extends Controller { /** * Display All Persons. @@ -35,7 +35,7 @@ class PersonController extends Controller public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('mediahub.person.show', [ - 'person' => Person::findOrFail($id), + 'person' => TmdbPerson::findOrFail($id), ]); } } diff --git a/app/Http/Controllers/PlaylistController.php b/app/Http/Controllers/PlaylistController.php index 73bae16c1..457abaae1 100644 --- a/app/Http/Controllers/PlaylistController.php +++ b/app/Http/Controllers/PlaylistController.php @@ -18,9 +18,9 @@ namespace App\Http\Controllers; use App\Http\Requests\StorePlaylistRequest; use App\Http\Requests\UpdatePlaylistRequest; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Playlist; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Repositories\ChatRepository; use App\Traits\TorrentMeta; use Illuminate\Http\Request; @@ -120,8 +120,8 @@ class PlaylistController extends Controller return view('playlist.show', [ 'playlist' => $playlist->load('user.group'), 'meta' => match (true) { - $randomTorrent?->category?->tv_meta => Tv::find($randomTorrent->tv_id), - $randomTorrent?->category?->movie_meta => Movie::find($randomTorrent->movie_id), + $randomTorrent?->category?->tv_meta => TmdbTv::find($randomTorrent->tmdb_tv_id), + $randomTorrent?->category?->movie_meta => TmdbMovie::find($randomTorrent->tmdb_movie_id), default => null, }, 'latestPlaylistTorrent' => $playlist->torrents()->orderByPivot('created_at', 'desc')->first(), diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php index d39286639..8c5990b3f 100644 --- a/app/Http/Controllers/RequestController.php +++ b/app/Http/Controllers/RequestController.php @@ -20,11 +20,11 @@ use App\Http\Requests\StoreTorrentRequestRequest; use App\Http\Requests\UpdateTorrentRequestRequest; use App\Models\Category; use App\Models\IgdbGame; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Resolution; use App\Models\TorrentRequest; use App\Models\TorrentRequestBounty; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\Type; use App\Repositories\ChatRepository; use App\Services\Igdb\IgdbScraper; @@ -67,20 +67,20 @@ class RequestController extends Controller ->whereKey($torrentRequest) ->exists(), 'meta' => match (true) { - ($torrentRequest->category->tv_meta && $torrentRequest->tv_id) => Tv::with([ + ($torrentRequest->category->tv_meta && $torrentRequest->tmdb_tv_id) => TmdbTv::with([ 'genres', 'credits' => ['person', 'occupation'], 'networks', 'seasons' ]) - ->find($torrentRequest->tv_id), - ($torrentRequest->category->movie_meta && $torrentRequest->movie_id) => Movie::with([ + ->find($torrentRequest->tmdb_tv_id), + ($torrentRequest->category->movie_meta && $torrentRequest->tmdb_movie_id) => TmdbMovie::with([ 'genres', 'credits' => ['person', 'occupation'], 'companies', 'collection' ]) - ->find($torrentRequest->movie_id), + ->find($torrentRequest->tmdb_movie_id), ($torrentRequest->category->game_meta && $torrentRequest->igdb) => IgdbGame::with([ 'genres', 'companies', @@ -118,8 +118,8 @@ class RequestController extends Controller 'category_id' => $request->category_id ?? Category::first('id')->id, 'title' => urldecode((string) $request->title), 'imdb' => $request->imdb, - 'movieId' => $request->movie_id, - 'tvId' => $request->tv_id, + 'movieId' => $request->tmdb_movie_id, + 'tvId' => $request->tmdb_tv_id, 'mal' => $request->mal, 'tvdb' => $request->tvdb, 'igdb' => $request->igdb, @@ -158,10 +158,10 @@ class RequestController extends Controller $category = $torrentRequest->category; match (true) { - $category->tv_meta && $torrentRequest->tv_id > 0 => new TMDBScraper()->tv($torrentRequest->tv_id), - $category->movie_meta && $torrentRequest->movie_id > 0 => new TMDBScraper()->movie($torrentRequest->movie_id), - $category->game_meta && $torrentRequest->igdb > 0 => new IgdbScraper()->game($torrentRequest->igdb), - default => null, + $category->tv_meta && $torrentRequest->tmdb_tv_id > 0 => new TMDBScraper()->tv($torrentRequest->tmdb_tv_id), + $category->movie_meta && $torrentRequest->tmdb_movie_id > 0 => new TMDBScraper()->movie($torrentRequest->tmdb_movie_id), + $category->game_meta && $torrentRequest->igdb > 0 => new IgdbScraper()->game($torrentRequest->igdb), + default => null, }; return to_route('requests.index') @@ -210,10 +210,10 @@ class RequestController extends Controller $category = $torrentRequest->category; match (true) { - $category->tv_meta && $torrentRequest->tv_id > 0 => new TMDBScraper()->tv($torrentRequest->tv_id), - $category->movie_meta && $torrentRequest->movie_id > 0 => new TMDBScraper()->movie($torrentRequest->movie_id), - $category->game_meta && $torrentRequest->igdb > 0 => new IgdbScraper()->game($torrentRequest->igdb), - default => null, + $category->tv_meta && $torrentRequest->tmdb_tv_id > 0 => new TMDBScraper()->tv($torrentRequest->tmdb_tv_id), + $category->movie_meta && $torrentRequest->tmdb_movie_id > 0 => new TMDBScraper()->movie($torrentRequest->tmdb_movie_id), + $category->game_meta && $torrentRequest->igdb > 0 => new IgdbScraper()->game($torrentRequest->igdb), + default => null, }; return to_route('requests.show', ['torrentRequest' => $torrentRequest]) diff --git a/app/Http/Controllers/RssController.php b/app/Http/Controllers/RssController.php index 3b3673dd7..0119a9cf6 100644 --- a/app/Http/Controllers/RssController.php +++ b/app/Http/Controllers/RssController.php @@ -18,7 +18,7 @@ namespace App\Http\Controllers; use App\DTO\TorrentSearchFiltersDTO; use App\Models\Category; -use App\Models\Genre; +use App\Models\TmdbGenre; use App\Models\Group; use App\Models\Resolution; use App\Models\Rss; @@ -56,7 +56,7 @@ class RssController extends Controller 'categories' => Category::select(['id', 'name', 'position'])->orderBy('position')->get(), 'types' => Type::select(['id', 'name', 'position'])->orderBy('position')->get(), 'resolutions' => Resolution::select(['id', 'name', 'position'])->orderBy('position')->get(), - 'genres' => Genre::orderBy('name')->get(), + 'genres' => TmdbGenre::orderBy('name')->get(), 'user' => $request->user(), ]); } @@ -221,7 +221,7 @@ class RssController extends Controller 'categories' => Category::select(['id', 'name', 'position'])->orderBy('position')->get(), 'types' => Type::select(['id', 'name', 'position'])->orderBy('position')->get(), 'resolutions' => Resolution::select(['id', 'name', 'position'])->orderBy('position')->get(), - 'genres' => Genre::orderBy('name')->get(), + 'genres' => TmdbGenre::orderBy('name')->get(), 'user' => $user, 'rss' => $rss, ]); diff --git a/app/Http/Controllers/SimilarTorrentController.php b/app/Http/Controllers/SimilarTorrentController.php index 8068206c6..ecc3a72cb 100644 --- a/app/Http/Controllers/SimilarTorrentController.php +++ b/app/Http/Controllers/SimilarTorrentController.php @@ -18,10 +18,10 @@ namespace App\Http\Controllers; use App\Models\Category; use App\Models\IgdbGame; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Torrent; use App\Models\TorrentRequest; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Services\Igdb\IgdbScraper; use App\Services\Tmdb\TMDBScraper; use Illuminate\Http\Request; @@ -38,11 +38,11 @@ class SimilarTorrentController extends Controller switch (true) { case $category->movie_meta: - $hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('movie_id', '=', $tmdbId)->exists(); + $hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('tmdb_movie_id', '=', $tmdbId)->exists(); abort_unless($hasTorrents, 404, 'No Similar Torrents Found'); - $meta = Movie::with([ + $meta = TmdbMovie::with([ 'genres', 'credits' => ['person', 'occupation'], 'companies' @@ -52,11 +52,11 @@ class SimilarTorrentController extends Controller break; case $category->tv_meta: - $hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('tv_id', '=', $tmdbId)->exists(); + $hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('tmdb_tv_id', '=', $tmdbId)->exists(); abort_unless($hasTorrents, 404, 'No Similar Torrents Found'); - $meta = Tv::with([ + $meta = TmdbTv::with([ 'genres', 'credits' => ['person', 'occupation'], 'companies', @@ -106,13 +106,13 @@ class SimilarTorrentController extends Controller $metaId === 0 || ( $category->movie_meta - && Torrent::where('category_id', '=', $category->id)->where('movie_id', '=', $metaId)->doesntExist() - && TorrentRequest::where('category_id', '=', $category->id)->where('movie_id', '=', $metaId)->doesntExist() + && Torrent::where('category_id', '=', $category->id)->where('tmdb_movie_id', '=', $metaId)->doesntExist() + && TorrentRequest::where('category_id', '=', $category->id)->where('tmdb_movie_id', '=', $metaId)->doesntExist() ) || ( $category->tv_meta - && Torrent::where('category_id', '=', $category->id)->where('tv_id', '=', $metaId)->doesntExist() - && TorrentRequest::where('category_id', '=', $category->id)->where('tv_id', '=', $metaId)->doesntExist() + && Torrent::where('category_id', '=', $category->id)->where('tmdb_tv_id', '=', $metaId)->doesntExist() + && TorrentRequest::where('category_id', '=', $category->id)->where('tmdb_tv_id', '=', $metaId)->doesntExist() ) || ( $category->game_meta diff --git a/app/Http/Controllers/Staff/RssController.php b/app/Http/Controllers/Staff/RssController.php index d87673223..9eaf5e35b 100644 --- a/app/Http/Controllers/Staff/RssController.php +++ b/app/Http/Controllers/Staff/RssController.php @@ -20,7 +20,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\Staff\StoreRssRequest; use App\Http\Requests\Staff\UpdateRssRequest; use App\Models\Category; -use App\Models\Genre; +use App\Models\TmdbGenre; use App\Models\Resolution; use App\Models\Rss; use App\Models\Type; @@ -51,7 +51,7 @@ class RssController extends Controller 'categories' => Category::select(['id', 'name', 'position'])->orderBy('position')->get(), 'types' => Type::select(['id', 'name', 'position'])->orderBy('position')->get(), 'resolutions' => Resolution::select(['id', 'name', 'position'])->orderBy('position')->get(), - 'genres' => Genre::orderBy('name')->get(), + 'genres' => TmdbGenre::orderBy('name')->get(), 'user' => $request->user(), ]); } @@ -84,7 +84,7 @@ class RssController extends Controller 'categories' => Category::select(['id', 'name', 'position'])->orderBy('position')->get(), 'types' => Type::select(['id', 'name', 'position'])->orderBy('position')->get(), 'resolutions' => Resolution::select(['id', 'name', 'position'])->orderBy('position')->get(), - 'genres' => Genre::orderBy('name')->get(), + 'genres' => TmdbGenre::orderBy('name')->get(), 'user' => $request->user(), 'rss' => $rss, ]); diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 7f483f490..56ee3b475 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -29,13 +29,13 @@ use App\Models\Distributor; use App\Models\History; use App\Models\IgdbGame; use App\Models\Keyword; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Region; use App\Models\Resolution; use App\Models\Scopes\ApprovedScope; use App\Models\Torrent; use App\Models\TorrentFile; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\Type; use App\Models\User; use App\Notifications\TorrentDeleted; @@ -101,31 +101,31 @@ class TorrentController extends Controller $meta = null; - if ($torrent->category->tv_meta && $torrent->tv_id) { - $meta = Tv::with([ + if ($torrent->category->tv_meta && $torrent->tmdb_tv_id) { + $meta = TmdbTv::with([ 'genres', 'credits' => ['person', 'occupation'], 'companies', 'networks', 'recommendedTv' => fn ($query) => $query - ->select('tv.id', 'tv.name', 'tv.poster', 'tv.first_air_date') + ->select('tmdb_tv.id', 'tmdb_tv.name', 'tmdb_tv.poster', 'tmdb_tv.first_air_date') ->withMin('torrents', 'category_id') ->has('torrents'), - ])->find($torrent->tv_id); + ])->find($torrent->tmdb_tv_id); } - if ($torrent->category->movie_meta && $torrent->movie_id) { - $meta = Movie::with([ + if ($torrent->category->movie_meta && $torrent->tmdb_movie_id) { + $meta = TmdbMovie::with([ 'genres', 'credits' => ['person', 'occupation'], 'companies', 'collection', 'recommendedMovies' => fn ($query) => $query - ->select('movies.id', 'movies.title', 'movies.poster', 'movies.release_date') + ->select('tmdb_movies.id', 'tmdb_movies.title', 'tmdb_movies.poster', 'tmdb_movies.release_date') ->withMin('torrents', 'category_id') ->has('torrents'), ]) - ->find($torrent->movie_id); + ->find($torrent->tmdb_movie_id); } if ($torrent->category->game_meta && $torrent->igdb) { @@ -260,10 +260,10 @@ class TorrentController extends Controller // Meta match (true) { - $category->tv_meta && $torrent->tv_id > 0 => new TMDBScraper()->tv($torrent->tv_id), - $category->movie_meta && $torrent->movie_id > 0 => new TMDBScraper()->movie($torrent->movie_id), - $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), - default => null, + $category->tv_meta && $torrent->tmdb_tv_id > 0 => new TMDBScraper()->tv($torrent->tmdb_tv_id), + $category->movie_meta && $torrent->tmdb_movie_id > 0 => new TMDBScraper()->movie($torrent->tmdb_movie_id), + $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), + default => null, }; return to_route('torrents.show', ['id' => $id]) @@ -361,8 +361,8 @@ class TorrentController extends Controller 'category_id' => $request->category_id ?? Category::query()->first()->id, 'title' => urldecode((string) $request->title), 'imdb' => $request->imdb, - 'movieId' => $request->movie_id, - 'tvId' => $request->tv_id, + 'movieId' => $request->tmdb_movie_id, + 'tvId' => $request->tmdb_tv_id, 'mal' => $request->mal, 'tvdb' => $request->tvdb, 'igdb' => $request->igdb, @@ -449,10 +449,10 @@ class TorrentController extends Controller // Meta match (true) { - $category->tv_meta && $torrent->tv_id > 0 => new TMDBScraper()->tv($torrent->tv_id), - $category->movie_meta && $torrent->movie_id > 0 => new TMDBScraper()->movie($torrent->movie_id), - $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), - default => null, + $category->tv_meta && $torrent->tmdb_tv_id > 0 => new TMDBScraper()->tv($torrent->tmdb_tv_id), + $category->movie_meta && $torrent->tmdb_movie_id > 0 => new TMDBScraper()->movie($torrent->tmdb_movie_id), + $category->game_meta && $torrent->igdb > 0 => new IgdbScraper()->game($torrent->igdb), + default => null, }; // Torrent Keywords System diff --git a/app/Http/Controllers/User/WishController.php b/app/Http/Controllers/User/WishController.php index a2efe0ba9..17280a196 100644 --- a/app/Http/Controllers/User/WishController.php +++ b/app/Http/Controllers/User/WishController.php @@ -58,7 +58,7 @@ class WishController extends Controller switch ($request->meta) { case 'movie': - $meta = (new Movie((int) $request->movie_id))->data; + $meta = (new Movie((int) $request->tmdb_movie_id))->data; if ($meta === null) { return to_route('users.wishes.index', ['user' => $user]) @@ -68,14 +68,14 @@ class WishController extends Controller $title = $meta['title'].' ('.$meta['release_date'].')'; Wish::create([ - 'user_id' => $user->id, - 'title' => $title, - 'movie_id' => $request->movie_id, + 'user_id' => $user->id, + 'title' => $title, + 'tmdb_movie_id' => $request->tmdb_movie_id, ]); break; case 'tv': - $meta = (new TV((int) $request->tv_id))->data; + $meta = (new TV((int) $request->tmdb_tv_id))->data; if ($meta === null) { return to_route('users.wishes.index', ['user' => $user]) @@ -85,9 +85,9 @@ class WishController extends Controller $title = $meta['name'].' ('.$meta['first_air_date'].')'; Wish::create([ - 'user_id' => $user->id, - 'title' => $title, - 'tv_id' => $request->tv_id, + 'user_id' => $user->id, + 'title' => $title, + 'tmdb_tv_id' => $request->tmdb_tv_id, ]); break; diff --git a/app/Http/Controllers/YearlyOverviewController.php b/app/Http/Controllers/YearlyOverviewController.php index e2d3fe889..b0216476c 100644 --- a/app/Http/Controllers/YearlyOverviewController.php +++ b/app/Http/Controllers/YearlyOverviewController.php @@ -55,7 +55,7 @@ class YearlyOverviewController extends Controller 'yearly-overview:'.$year.':top-movies', fn () => Torrent::with('movie') ->select([ - 'movie_id', + 'tmdb_movie_id', DB::raw('COUNT(h.user_id) as download_count'), DB::raw('MIN(category_id) as category_id'), ]) @@ -67,10 +67,10 @@ class YearlyOverviewController extends Controller 'h', fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id') ) - ->where('movie_id', '!=', 0) - ->whereNotNull('movie_id') + ->where('tmdb_movie_id', '!=', 0) + ->whereNotNull('tmdb_movie_id') ->whereRelation('category', 'movie_meta', '=', true) - ->groupBy('movie_id') + ->groupBy('tmdb_movie_id') ->orderByDesc('download_count') ->take(10) ->get() @@ -79,7 +79,7 @@ class YearlyOverviewController extends Controller 'yearly-overview:'.$year.':bottom-movies', fn () => Torrent::with('movie') ->select([ - 'movie_id', + 'tmdb_movie_id', DB::raw('COUNT(h.user_id) as download_count'), DB::raw('MIN(category_id) as category_id'), ]) @@ -91,10 +91,10 @@ class YearlyOverviewController extends Controller 'h', fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id') ) - ->where('movie_id', '!=', 0) - ->whereNotNull('movie_id') + ->where('tmdb_movie_id', '!=', 0) + ->whereNotNull('tmdb_movie_id') ->whereRelation('category', 'movie_meta', '=', true) - ->groupBy('movie_id') + ->groupBy('tmdb_movie_id') ->orderBy('download_count') ->take(5) ->get() @@ -103,7 +103,7 @@ class YearlyOverviewController extends Controller 'yearly-overview:'.$year.':top-tv', fn () => Torrent::with('tv') ->select([ - 'tv_id', + 'tmdb_tv_id', DB::raw('COUNT(h.user_id) as download_count'), DB::raw('MIN(category_id) as category_id'), ]) @@ -115,10 +115,10 @@ class YearlyOverviewController extends Controller 'h', fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id') ) - ->where('tv_id', '!=', 0) - ->whereNotNull('tv_id') + ->where('tmdb_tv_id', '!=', 0) + ->whereNotNull('tmdb_tv_id') ->whereRelation('category', 'tv_meta', '=', true) - ->groupBy('tv_id') + ->groupBy('tmdb_tv_id') ->orderByDesc('download_count') ->take(10) ->get() @@ -127,7 +127,7 @@ class YearlyOverviewController extends Controller 'yearly-overview:'.$year.':bottom-tv', fn () => Torrent::with('tv') ->select([ - 'tv_id', + 'tmdb_tv_id', DB::raw('COUNT(h.user_id) as download_count'), DB::raw('MIN(category_id) as category_id'), ]) @@ -139,10 +139,10 @@ class YearlyOverviewController extends Controller 'h', fn ($join) => $join->on('torrents.id', '=', 'h.torrent_id') ) - ->where('tv_id', '!=', 0) - ->whereNotNull('tv_id') + ->where('tmdb_tv_id', '!=', 0) + ->whereNotNull('tmdb_tv_id') ->whereRelation('category', 'tv_meta', '=', true) - ->groupBy('tv_id') + ->groupBy('tmdb_tv_id') ->orderBy('download_count') ->take(5) ->get() diff --git a/app/Http/Livewire/Comment.php b/app/Http/Livewire/Comment.php index bd0464b13..77d57b612 100644 --- a/app/Http/Livewire/Comment.php +++ b/app/Http/Livewire/Comment.php @@ -30,7 +30,7 @@ use App\Achievements\UserMadeComment; use App\Achievements\UserMadeTenComments; use App\Enums\ModerationStatus; use App\Models\Article; -use App\Models\Collection; +use App\Models\TmdbCollection; use App\Models\Playlist; use App\Models\Ticket; use App\Models\Torrent; @@ -49,7 +49,7 @@ class Comment extends Component protected ChatRepository $chatRepository; - public null|Article|Collection|Playlist|Ticket|Torrent|TorrentRequest $model; + public null|Article|TmdbCollection|Playlist|Ticket|Torrent|TorrentRequest $model; public \App\Models\Comment $comment; @@ -195,7 +195,7 @@ class Comment extends Component $this->chatRepository->systemMessage($username.' has left a comment on Article [url='.href_article($this->model).']'.$this->model->title.'[/url]'); break; - case $this->model instanceof Collection: + case $this->model instanceof TmdbCollection: $this->chatRepository->systemMessage($username.' has left a comment on Collection [url='.href_collection($this->model).']'.$this->model->name.'[/url]'); break; diff --git a/app/Http/Livewire/Comments.php b/app/Http/Livewire/Comments.php index 606d411e1..a7fc85720 100644 --- a/app/Http/Livewire/Comments.php +++ b/app/Http/Livewire/Comments.php @@ -30,7 +30,7 @@ use App\Achievements\UserMadeComment; use App\Achievements\UserMadeTenComments; use App\Enums\ModerationStatus; use App\Models\Article; -use App\Models\Collection; +use App\Models\TmdbCollection; use App\Models\Playlist; use App\Models\Ticket; use App\Models\Torrent; @@ -56,7 +56,7 @@ class Comments extends Component public ?User $user; - public null|Article|Collection|Playlist|Ticket|Torrent|TorrentRequest $model; + public null|Article|TmdbCollection|Playlist|Ticket|Torrent|TorrentRequest $model; public bool $anon = false; @@ -158,7 +158,7 @@ class Comments extends Component $this->chatRepository->systemMessage($username.' has left a comment on Article [url='.href_article($this->model).']'.$this->model->title.'[/url]'); break; - case $this->model instanceof Collection: + case $this->model instanceof TmdbCollection: $this->chatRepository->systemMessage($username.' has left a comment on Collection [url='.href_collection($this->model).']'.$this->model->name.'[/url]'); break; diff --git a/app/Http/Livewire/MissingMediaSearch.php b/app/Http/Livewire/MissingMediaSearch.php index fce6f63f4..760b929c4 100644 --- a/app/Http/Livewire/MissingMediaSearch.php +++ b/app/Http/Livewire/MissingMediaSearch.php @@ -16,7 +16,7 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Type; use App\Traits\LivewireSort; use Livewire\Attributes\Computed; @@ -50,12 +50,12 @@ class MissingMediaSearch extends Component public int $perPage = 50; /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function medias(): \Illuminate\Pagination\LengthAwarePaginator { - return Movie::with(['torrents:movie_id,tv_id,resolution_id,type_id' => ['resolution:id,position,name']]) + return TmdbMovie::with(['torrents:tmdb_movie_id,tmdb_tv_id,resolution_id,type_id' => ['resolution:id,position,name']]) ->when($this->name, fn ($query) => $query->where('title', 'LIKE', '%'.$this->name.'%')) ->when($this->year, fn ($query) => $query->where('release_date', 'LIKE', '%'.$this->year.'%')) ->withCount(['requests' => fn ($query) => $query->whereNull('torrent_id')->whereNull('claimed')]) diff --git a/app/Http/Livewire/RandomMedia.php b/app/Http/Livewire/RandomMedia.php index 00dda0bac..60da6abd9 100644 --- a/app/Http/Livewire/RandomMedia.php +++ b/app/Http/Livewire/RandomMedia.php @@ -16,8 +16,8 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Tv; -use App\Models\Movie; +use App\Models\TmdbTv; +use App\Models\TmdbMovie; use Illuminate\Support\Facades\Redis; use Livewire\Attributes\Computed; use Livewire\Component; @@ -25,7 +25,7 @@ use Livewire\Component; class RandomMedia extends Component { /** - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection */ #[Computed] final public function movies(): \Illuminate\Support\Collection @@ -34,7 +34,7 @@ class RandomMedia extends Component $movieIds = Redis::connection('cache')->command('SRANDMEMBER', [$cacheKey, 3]); - return Movie::query() + return TmdbMovie::query() ->select(['id', 'backdrop', 'title', 'release_date']) ->withMin('torrents', 'category_id') ->whereIn('id', $movieIds) @@ -42,7 +42,7 @@ class RandomMedia extends Component } /** - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection */ #[Computed] final public function movies2(): \Illuminate\Support\Collection @@ -51,7 +51,7 @@ class RandomMedia extends Component $movieIds = Redis::connection('cache')->command('SRANDMEMBER', [$cacheKey, 3]); - return Movie::query() + return TmdbMovie::query() ->select(['id', 'backdrop', 'title', 'release_date']) ->withMin('torrents', 'category_id') ->whereIn('id', $movieIds) @@ -59,7 +59,7 @@ class RandomMedia extends Component } /** - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection */ #[Computed] final public function tvs(): \Illuminate\Support\Collection @@ -68,7 +68,7 @@ class RandomMedia extends Component $tvIds = Redis::connection('cache')->command('SRANDMEMBER', [$cacheKey, 3]); - return Tv::query() + return TmdbTv::query() ->select(['id', 'backdrop', 'name', 'first_air_date']) ->withMin('torrents', 'category_id') ->whereIn('id', $tvIds) diff --git a/app/Http/Livewire/SimilarTorrent.php b/app/Http/Livewire/SimilarTorrent.php index 0ade0b88c..3f091e930 100644 --- a/app/Http/Livewire/SimilarTorrent.php +++ b/app/Http/Livewire/SimilarTorrent.php @@ -21,12 +21,12 @@ use App\Models\Category; use App\Models\Distributor; use App\Models\History; use App\Models\IgdbGame; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Region; use App\Models\Resolution; use App\Models\Torrent; use App\Models\TorrentRequest; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\Type; use App\Models\User; use App\Notifications\TorrentsDeleted; @@ -46,7 +46,7 @@ class SimilarTorrent extends Component public Category $category; - public Movie|Tv|Game $work; + public TmdbMovie|TmdbTv|Game $work; public ?int $tmdbId; @@ -203,9 +203,9 @@ class SimilarTorrent extends Component final public function boot(): void { - if ($this->work instanceof Movie) { + if ($this->work instanceof TmdbMovie) { $this->work->setAttribute('meta', 'movie'); - } elseif ($this->work instanceof Tv) { + } elseif ($this->work instanceof TmdbTv) { $this->work->setAttribute('meta', 'tv'); } } @@ -280,8 +280,8 @@ class SimilarTorrent extends Component $this->category->tv_meta, fn ($query) => $query->whereRelation('category', 'tv_meta', '=', true), ) - ->when($this->category->tv_meta, fn ($query) => $query->where('tv_id', '=', $this->tmdbId)) - ->when($this->category->movie_meta, fn ($query) => $query->where('movie_id', '=', $this->tmdbId)) + ->when($this->category->tv_meta, fn ($query) => $query->where('tmdb_tv_id', '=', $this->tmdbId)) + ->when($this->category->movie_meta, fn ($query) => $query->where('tmdb_movie_id', '=', $this->tmdbId)) ->when($this->category->game_meta, fn ($query) => $query->where('igdb', '=', $this->tmdbId)) ->where((new TorrentSearchFiltersDTO( name: $this->name, @@ -390,8 +390,8 @@ class SimilarTorrent extends Component { return TorrentRequest::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution']) ->withCount(['comments']) - ->when($this->category->movie_meta, fn ($query) => $query->where('movie_id', '=', $this->tmdbId)) - ->when($this->category->tv_meta, fn ($query) => $query->where('tv_id', '=', $this->tmdbId)) + ->when($this->category->movie_meta, fn ($query) => $query->where('tmdb_movie_id', '=', $this->tmdbId)) + ->when($this->category->tv_meta, fn ($query) => $query->where('tmdb_tv_id', '=', $this->tmdbId)) ->when($this->category->game_meta, fn ($query) => $query->where('igdb', '=', $this->tmdbId)) ->where('category_id', '=', $this->category->id) ->when( @@ -432,8 +432,8 @@ class SimilarTorrent extends Component $torrents = Torrent::whereKey($this->checked)->get(); $users = []; $title = match (true) { - $this->category->movie_meta => ($movie = Movie::find($this->tmdbId))->title.' ('.$movie->release_date->format('Y').')', - $this->category->tv_meta => ($tv = Tv::find($this->tmdbId))->name.' ('.$tv->first_air_date->format('Y').')', + $this->category->movie_meta => ($movie = TmdbMovie::find($this->tmdbId))->title.' ('.$movie->release_date->format('Y').')', + $this->category->tv_meta => ($tv = TmdbTv::find($this->tmdbId))->name.' ('.$tv->first_air_date->format('Y').')', $this->category->game_meta => ($game = IgdbGame::find($this->igdbId))->name.' ('.$game->first_release_date->format('Y').')', default => $torrents->pluck('name')->join(', '), }; diff --git a/app/Http/Livewire/CollectionSearch.php b/app/Http/Livewire/TmdbCollectionSearch.php similarity index 88% rename from app/Http/Livewire/CollectionSearch.php rename to app/Http/Livewire/TmdbCollectionSearch.php index b2c533c20..36ba6939d 100644 --- a/app/Http/Livewire/CollectionSearch.php +++ b/app/Http/Livewire/TmdbCollectionSearch.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Collection; +use App\Models\TmdbCollection; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; use Livewire\WithPagination; -class CollectionSearch extends Component +class TmdbCollectionSearch extends Component { use WithPagination; @@ -37,12 +37,12 @@ class CollectionSearch extends Component } /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function collections(): \Illuminate\Pagination\LengthAwarePaginator { - return Collection::withCount('movie') + return TmdbCollection::withCount('movie') ->with('movie') ->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%')) ->oldest('name') @@ -51,7 +51,7 @@ class CollectionSearch extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.collection-search', [ + return view('livewire.tmdb-collection-search', [ 'collections' => $this->collections, ]); } diff --git a/app/Http/Livewire/CompanySearch.php b/app/Http/Livewire/TmdbCompanySearch.php similarity index 91% rename from app/Http/Livewire/CompanySearch.php rename to app/Http/Livewire/TmdbCompanySearch.php index 3b2dc6f9e..624312f29 100644 --- a/app/Http/Livewire/CompanySearch.php +++ b/app/Http/Livewire/TmdbCompanySearch.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Company; +use App\Models\TmdbCompany; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; use Livewire\WithPagination; -class CompanySearch extends Component +class TmdbCompanySearch extends Component { use WithPagination; @@ -37,12 +37,12 @@ class CompanySearch extends Component } /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function companies(): \Illuminate\Pagination\LengthAwarePaginator { - return Company::query() + return TmdbCompany::query() ->withCount([ 'movie' => fn ($query) => $query->has('torrents'), 'tv' => fn ($query) => $query->has('torrents'), @@ -55,7 +55,7 @@ class CompanySearch extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.company-search', [ + return view('livewire.tmdb-company-search', [ 'companies' => $this->companies, ]); } diff --git a/app/Http/Livewire/NetworkSearch.php b/app/Http/Livewire/TmdbNetworkSearch.php similarity index 90% rename from app/Http/Livewire/NetworkSearch.php rename to app/Http/Livewire/TmdbNetworkSearch.php index ccdfa7e04..8d22acf58 100644 --- a/app/Http/Livewire/NetworkSearch.php +++ b/app/Http/Livewire/TmdbNetworkSearch.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Network; +use App\Models\TmdbNetwork; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; use Livewire\WithPagination; -class NetworkSearch extends Component +class TmdbNetworkSearch extends Component { use WithPagination; @@ -37,12 +37,12 @@ class NetworkSearch extends Component } /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function networks(): \Illuminate\Pagination\LengthAwarePaginator { - return Network::query() + return TmdbNetwork::query() ->withCount([ 'tv' => fn ($query) => $query->has('torrents'), ]) @@ -54,7 +54,7 @@ class NetworkSearch extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.network-search', [ + return view('livewire.tmdb-network-search', [ 'networks' => $this->networks, ]); } diff --git a/app/Http/Livewire/PersonCredit.php b/app/Http/Livewire/TmdbPersonCredit.php similarity index 97% rename from app/Http/Livewire/PersonCredit.php rename to app/Http/Livewire/TmdbPersonCredit.php index bcb4fdd18..424f964fd 100644 --- a/app/Http/Livewire/PersonCredit.php +++ b/app/Http/Livewire/TmdbPersonCredit.php @@ -17,16 +17,16 @@ declare(strict_types=1); namespace App\Http\Livewire; use App\Enums\Occupation; -use App\Models\Person; +use App\Models\TmdbPerson; use App\Models\Torrent; use App\Models\User; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; -class PersonCredit extends Component +class TmdbPersonCredit extends Component { - public Person $person; + public TmdbPerson $person; #TODO: Update URL attributes once Livewire 3 fixes upstream bug. See: https://github.com/livewire/livewire/discussions/7746 @@ -168,8 +168,8 @@ class PersonCredit extends Component 'user_id', 'season_number', 'episode_number', - 'movie_id', - 'tv_id', + 'tmdb_movie_id', + 'tmdb_tv_id', 'free', 'doubleup', 'highspeed', @@ -229,12 +229,12 @@ class PersonCredit extends Component ->where( fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIntegerInRaw('movie_id', $movieIds) + ->whereIntegerInRaw('tmdb_movie_id', $movieIds) ) ->orWhere( fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIntegerInRaw('tv_id', $tvIds) + ->whereIntegerInRaw('tmdb_tv_id', $tvIds) ) ) ->get(); @@ -245,7 +245,7 @@ class PersonCredit extends Component // Memoizing and avoiding casts reduces runtime duration from 70ms to 40ms. // If accessing laravel's attributes array directly, it's reduced to 11ms, // but the attributes array is marked as protected so we can't access it. - $tmdb = $torrent->getAttributeValue('movie_id') ?: $torrent->getAttributeValue('tv_id'); + $tmdb = $torrent->getAttributeValue('tmdb_movie_id') ?: $torrent->getAttributeValue('tmdb_tv_id'); $type = $torrent->getRelationValue('type')->getAttributeValue('name'); switch ($torrent->getAttributeValue('meta')) { @@ -378,7 +378,7 @@ class PersonCredit extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.person-credit', [ + return view('livewire.tmdb-person-credit', [ 'user' => User::with(['group'])->findOrFail(auth()->user()->id), 'personalFreeleech' => $this->personalFreeleech, 'medias' => $this->medias, diff --git a/app/Http/Livewire/PersonSearch.php b/app/Http/Livewire/TmdbPersonSearch.php similarity index 87% rename from app/Http/Livewire/PersonSearch.php rename to app/Http/Livewire/TmdbPersonSearch.php index 69ce49180..c44aff7e4 100644 --- a/app/Http/Livewire/PersonSearch.php +++ b/app/Http/Livewire/TmdbPersonSearch.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Person; +use App\Models\TmdbPerson; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; use Livewire\WithPagination; -class PersonSearch extends Component +class TmdbPersonSearch extends Component { use WithPagination; @@ -46,12 +46,12 @@ class PersonSearch extends Component } /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function persons(): \Illuminate\Pagination\LengthAwarePaginator { - return Person::select(['id', 'still', 'name']) + return TmdbPerson::select(['id', 'still', 'name']) ->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%')) ->when($this->occupationIds !== [], fn ($query) => $query->whereHas('credits', fn ($query) => $query->whereIn('occupation_id', $this->occupationIds))) ->when($this->firstCharacter !== '', fn ($query) => $query->where('name', 'LIKE', $this->firstCharacter.'%')) @@ -60,12 +60,12 @@ class PersonSearch extends Component } /** - * @return \Illuminate\Database\Eloquent\Collection + * @return \Illuminate\Database\Eloquent\Collection */ #[Computed] final public function firstCharacters(): \Illuminate\Database\Eloquent\Collection { - return Person::selectRaw('substr(name, 1, 1) as alpha, count(*) as count') + return TmdbPerson::selectRaw('substr(name, 1, 1) as alpha, count(*) as count') ->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%')) ->when($this->occupationIds !== [], fn ($query) => $query->whereHas('credits', fn ($query) => $query->whereIn('occupation_id', $this->occupationIds))) ->groupBy('alpha') @@ -75,7 +75,7 @@ class PersonSearch extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.person-search', [ + return view('livewire.tmdb-person-search', [ 'persons' => $this->persons, 'firstCharacters' => $this->firstCharacters, ]); diff --git a/app/Http/Livewire/TvSearch.php b/app/Http/Livewire/TmdbTvSearch.php similarity index 89% rename from app/Http/Livewire/TvSearch.php rename to app/Http/Livewire/TmdbTvSearch.php index 081d85068..d53889746 100644 --- a/app/Http/Livewire/TvSearch.php +++ b/app/Http/Livewire/TmdbTvSearch.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Http\Livewire; -use App\Models\Tv; +use App\Models\TmdbTv; use Livewire\Attributes\Computed; use Livewire\Attributes\Url; use Livewire\Component; use Livewire\WithPagination; -class TvSearch extends Component +class TmdbTvSearch extends Component { use WithPagination; @@ -37,12 +37,12 @@ class TvSearch extends Component } /** - * @return \Illuminate\Pagination\LengthAwarePaginator + * @return \Illuminate\Pagination\LengthAwarePaginator */ #[Computed] final public function shows(): \Illuminate\Pagination\LengthAwarePaginator { - return Tv::with(['networks', 'genres']) + return TmdbTv::with(['networks', 'genres']) ->withCount('seasons') ->when($this->search, fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%')) ->oldest('name') @@ -51,7 +51,7 @@ class TvSearch extends Component final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application { - return view('livewire.tv-search', [ + return view('livewire.tmdb-tv-search', [ 'shows' => $this->shows, ]); } diff --git a/app/Http/Livewire/Top10.php b/app/Http/Livewire/Top10.php index 32a29984b..e6497a44c 100644 --- a/app/Http/Livewire/Top10.php +++ b/app/Http/Livewire/Top10.php @@ -80,8 +80,8 @@ class Top10 extends Component $this->validate(); $metaIdColumn = match ($this->metaType) { - 'tv_meta' => 'tv_id', - default => 'movie_id', + 'tv_meta' => 'tmdb_tv_id', + default => 'tmdb_movie_id', }; return cache()->remember( @@ -122,8 +122,8 @@ class Top10 extends Component $this->validate(); $metaIdColumn = match ($this->metaType) { - 'tv_meta' => 'tv_id', - default => 'movie_id', + 'tv_meta' => 'tmdb_tv_id', + default => 'tmdb_movie_id', }; return cache()->remember( @@ -171,8 +171,8 @@ class Top10 extends Component $this->validate(); $metaIdColumn = match ($this->metaType) { - 'tv_meta' => 'tv_id', - default => 'movie_id', + 'tv_meta' => 'tmdb_tv_id', + default => 'tmdb_movie_id', }; return cache()->remember( diff --git a/app/Http/Livewire/TorrentRequestSearch.php b/app/Http/Livewire/TorrentRequestSearch.php index 1c403326e..a75125654 100644 --- a/app/Http/Livewire/TorrentRequestSearch.php +++ b/app/Http/Livewire/TorrentRequestSearch.php @@ -17,8 +17,8 @@ declare(strict_types=1); namespace App\Http\Livewire; use App\Models\Category; -use App\Models\Genre; -use App\Models\Movie; +use App\Models\TmdbGenre; +use App\Models\TmdbMovie; use App\Models\Resolution; use App\Models\TorrentRequest; use App\Models\Type; @@ -152,21 +152,21 @@ class TorrentRequestSearch extends Component } /** - * @return \Illuminate\Database\Eloquent\Collection + * @return \Illuminate\Database\Eloquent\Collection */ #[Computed(seconds: 3600, cache: true)] final public function genres(): \Illuminate\Database\Eloquent\Collection { - return Genre::query()->orderBy('name')->get(); + return TmdbGenre::query()->orderBy('name')->get(); } /** - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection */ #[Computed(seconds: 3600, cache: true)] final public function primaryLanguages(): \Illuminate\Support\Collection { - return Movie::query() + return TmdbMovie::query() ->select('original_language') ->distinct() ->orderBy('original_language') @@ -240,7 +240,7 @@ class TorrentRequestSearch extends Component ->when($this->categoryIds !== [], fn ($query) => $query->whereIntegerInRaw('category_id', $this->categoryIds)) ->when($this->typeIds !== [], fn ($query) => $query->whereIntegerInRaw('type_id', $this->typeIds)) ->when($this->resolutionIds !== [], fn ($query) => $query->whereIntegerInRaw('resolution_id', $this->resolutionIds)) - ->when($this->tmdbId !== null, fn ($query) => $query->where(fn ($query) => $query->where('movie_id', '=', $this->tmdbId)->orWhere('tv_id', '=', $this->tmdbId))) + ->when($this->tmdbId !== null, fn ($query) => $query->where(fn ($query) => $query->where('tmdb_movie_id', '=', $this->tmdbId)->orWhere('tmdb_tv_id', '=', $this->tmdbId))) ->when($this->imdbId !== '', fn ($query) => $query->where('imdb', '=', (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId))) ->when($this->tvdbId !== null, fn ($query) => $query->where('tvdb', '=', $this->tvdbId)) ->when($this->malId !== null, fn ($query) => $query->where('mal', '=', $this->malId)) @@ -252,12 +252,12 @@ class TorrentRequestSearch extends Component ->where( fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIn('movie_id', DB::table('genre_movie')->select('movie_id')->whereIn('genre_id', $this->genreIds)) + ->whereIn('tmdb_movie_id', DB::table('tmdb_genre_tmdb_movie')->select('tmdb_movie_id')->whereIn('tmdb_genre_id', $this->genreIds)) ) ->orWhere( fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIn('tv_id', DB::table('genre_tv')->select('tv_id')->whereIn('genre_id', $this->genreIds)) + ->whereIn('tmdb_tv_id', DB::table('tmdb_genre_tmdb_tv')->select('tmdb_tv_id')->whereIn('tmdb_genre_id', $this->genreIds)) ) ) ) diff --git a/app/Http/Livewire/TorrentSearch.php b/app/Http/Livewire/TorrentSearch.php index a42993c25..eefaaf5ed 100644 --- a/app/Http/Livewire/TorrentSearch.php +++ b/app/Http/Livewire/TorrentSearch.php @@ -19,12 +19,12 @@ namespace App\Http\Livewire; use App\DTO\TorrentSearchFiltersDTO; use App\Models\Category; use App\Models\Distributor; -use App\Models\Genre; -use App\Models\Movie; +use App\Models\TmdbGenre; +use App\Models\TmdbMovie; use App\Models\Region; use App\Models\Resolution; use App\Models\Torrent; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Models\Type; use App\Traits\CastLivewireProperties; use App\Traits\LivewireSort; @@ -295,12 +295,12 @@ class TorrentSearch extends Component } /** - * @return \Illuminate\Database\Eloquent\Collection + * @return \Illuminate\Database\Eloquent\Collection */ #[Computed(seconds: 3600, cache: true)] final public function genres(): \Illuminate\Database\Eloquent\Collection { - return Genre::query()->orderBy('name')->get(); + return TmdbGenre::query()->orderBy('name')->get(); } /** @@ -322,12 +322,12 @@ class TorrentSearch extends Component } /** - * @return \Illuminate\Support\Collection + * @return \Illuminate\Support\Collection */ #[Computed(seconds: 3600, cache: true)] final public function primaryLanguages(): \Illuminate\Support\Collection { - return Movie::query() + return TmdbMovie::query() ->select('original_language') ->distinct() ->orderBy('original_language') @@ -527,7 +527,7 @@ class TorrentSearch extends Component $isSqlAllowed = (($user->group->is_modo || $user->group->is_torrent_modo || $user->group->is_editor) && $this->driver === 'sql') || $this->description || $this->mediainfo; $groupQuery = Torrent::query() - ->select('movie_id', 'tv_id') + ->select('tmdb_movie_id', 'tmdb_tv_id') ->selectRaw('MAX(sticky) as sticky') ->selectRaw('MAX(bumped_at) as bumped_at') ->selectRaw('MAX(created_at) as created_at') @@ -539,10 +539,10 @@ class TorrentSearch extends Component END) AS meta SQL) ->havingNotNull('meta') - ->where(fn ($query) => $query->where('movie_id', '>', 0)->orWhere('tv_id', '>', 0)) + ->where(fn ($query) => $query->where('tmdb_movie_id', '>', 0)->orWhere('tmdb_tv_id', '>', 0)) ->where('imdb', '>', 0) ->where($this->filters()->toSqlQueryBuilder()) - ->groupBy('movie_id', 'tv_id') + ->groupBy('tmdb_movie_id', 'tmdb_tv_id') ->latest('sticky') ->orderBy($this->sortField, $this->sortDirection); @@ -554,50 +554,41 @@ class TorrentSearch extends Component ->index(config('scout.prefix').'torrents') ->search($this->name, [ 'sort' => ['sticky:desc', $this->sortField.':'.$this->sortDirection,], - 'filter' => [...$this->filters()->toMeilisearchFilter(), 'imdb != 0', ['movie_id > 0', 'tv_id > 0']], + 'filter' => [...$this->filters()->toMeilisearchFilter(), 'imdb != 0', ['tmdb_movie_id > 0', 'tmdb_tv_id > 0']], 'matchingStrategy' => 'all', 'page' => (int) $this->getPage(), 'hitsPerPage' => min($this->perPage, 100), - 'attributesToRetrieve' => ['movie_id', 'tv_id'], + 'attributesToRetrieve' => ['tmdb_movie_id', 'tmdb_tv_id'], 'distinct' => 'imdb', ]); $ids = []; foreach ($results->getHits() as $result) { - if ($result['movie_id']) { - $ids[] = "tmdb-movie:{$result['movie_id']}"; - } elseif ($result['tv_id']) { - $ids[] = "tmdb-tv:{$result['tv_id']}"; + if ($result['tmdb_movie_id']) { + $ids[] = "tmdb-movie:{$result['tmdb_movie_id']}"; + } elseif ($result['tmdb_tv_id']) { + $ids[] = "tmdb-tv:{$result['tmdb_tv_id']}"; } } - // dd($ids) - - // dd([ - // 'movie_id' => array_column($results->getHits(), 'movie_id'), - // 'tv_id' => array_column($results->getHits(), 'tv_id'), - // ]); - $groups = $groupQuery ->where( fn ($query) => $query - ->whereIntegerInRaw('movie_id', array_filter(array_column($results->getHits(), 'movie_id'))) - ->orWhereIntegerInRaw('tv_id', array_filter(array_column($results->getHits(), 'tv_id'))) + ->whereIntegerInRaw('tmdb_movie_id', array_filter(array_column($results->getHits(), 'tmdb_movie_id'))) + ->orWhereIntegerInRaw('tmdb_tv_id', array_filter(array_column($results->getHits(), 'tmdb_tv_id'))) ) ->get() - ->sortBy(fn ($group) => array_search($group->movie_id ? "tmdb-movie:{$group->movie_id}" : "tmdb-tv:{$group->tv_id}", $ids)); - - // dd($groups); + ->sortBy(fn ($group) => array_search($group->tmdb_movie_id ? "tmdb-movie:{$group->tmdb_movie_id}" : "tmdb-tv:{$group->tmdb_tv_id}", $ids)); $groups = new LengthAwarePaginator($groups, $results->getTotalHits(), $this->perPage, $this->getPage()); } - $movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('movie_id'); - $tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tv_id'); + $movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('tmdb_movie_id'); + $tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tmdb_tv_id'); - $movies = Movie::with('genres', 'directors')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); - $tv = Tv::with('genres', 'creators')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); + $movies = TmdbMovie::with('genres', 'directors')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); + $tv = TmdbTv::with('genres', 'creators')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); $torrents = Torrent::query() ->with(['type:id,name,position', 'resolution:id,name,position']) @@ -613,8 +604,8 @@ class TorrentSearch extends Component 'user_id', 'season_number', 'episode_number', - 'movie_id', - 'tv_id', + 'tmdb_movie_id', + 'tmdb_tv_id', 'free', 'doubleup', 'highspeed', @@ -675,12 +666,12 @@ class TorrentSearch extends Component ->where( fn ($query) => $query ->whereRelation('category', 'movie_meta', '=', true) - ->whereIntegerInRaw('movie_id', $movieIds) + ->whereIntegerInRaw('tmdb_movie_id', $movieIds) ) ->orWhere( fn ($query) => $query ->whereRelation('category', 'tv_meta', '=', true) - ->whereIntegerInRaw('tv_id', $tvIds) + ->whereIntegerInRaw('tmdb_tv_id', $tvIds) ) ) ->where($this->filters()->toSqlQueryBuilder()) @@ -692,7 +683,7 @@ class TorrentSearch extends Component // Memoizing and avoiding casts reduces runtime duration from 70ms to 40ms. // If accessing laravel's attributes array directly, it's reduced to 11ms, // but the attributes array is marked as protected so we can't access it. - $tmdb = $torrent->getAttributeValue('movie_id') ?: $torrent->getAttributeValue('tv_id'); + $tmdb = $torrent->getAttributeValue('tmdb_movie_id') ?: $torrent->getAttributeValue('tmdb_tv_id'); $type = $torrent->getRelationValue('type')->getAttributeValue('name'); switch ($torrent->getAttributeValue('meta')) { @@ -777,10 +768,10 @@ class TorrentSearch extends Component $medias = $groups->through(function ($group) use ($groupedTorrents, $movies, $tv) { switch ($group->meta) { case 'movie': - if ($movies->has($group->movie_id)) { - $media = $movies[$group->movie_id]; + if ($movies->has($group->tmdb_movie_id)) { + $media = $movies[$group->tmdb_movie_id]; $media->setAttribute('meta', 'movie'); - $media->setRelation('torrents', $groupedTorrents['movie'][$group->movie_id] ?? []); + $media->setRelation('torrents', $groupedTorrents['movie'][$group->tmdb_movie_id] ?? []); $media->setAttribute('category_id', $media->torrents['category_id']); } else { $media = null; @@ -788,10 +779,10 @@ class TorrentSearch extends Component break; case 'tv': - if ($tv->has($group->tv_id)) { - $media = $tv[$group->tv_id]; + if ($tv->has($group->tmdb_tv_id)) { + $media = $tv[$group->tmdb_tv_id]; $media->setAttribute('meta', 'tv'); - $media->setRelation('torrents', $groupedTorrents['tv'][$group->tv_id] ?? []); + $media->setRelation('torrents', $groupedTorrents['tv'][$group->tmdb_tv_id] ?? []); $media->setAttribute('category_id', $media->torrents['category_id']); } else { $media = null; @@ -848,7 +839,7 @@ class TorrentSearch extends Component } $groups = Torrent::query() - ->select('movie_id', 'tv_id') + ->select('tmdb_movie_id', 'tmdb_tv_id') ->selectRaw('MAX(sticky) as sticky') ->selectRaw('MAX(bumped_at) as bumped_at') ->selectRaw('SUM(times_completed) as times_completed') @@ -860,27 +851,27 @@ class TorrentSearch extends Component END AS meta SQL) ->havingNotNull('meta') - ->where(fn ($query) => $query->where('movie_id', '!=', 0)->orWhere('tv_id', '!=', 0)) + ->where(fn ($query) => $query->where('tmdb_movie_id', '!=', 0)->orWhere('tmdb_tv_id', '!=', 0)) ->where($this->filters()->toSqlQueryBuilder()) - ->groupBy('movie_id', 'tv_id') + ->groupBy('tmdb_movie_id', 'tmdb_tv_id') ->latest('sticky') ->orderBy($this->sortField, $this->sortDirection) ->paginate(min($this->perPage, 100)); - $movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('movie_id'); - $tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tv_id'); + $movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('tmdb_movie_id'); + $tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tmdb_tv_id'); - $movies = Movie::with('genres', 'directors')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); - $tv = Tv::with('genres', 'creators')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); + $movies = TmdbMovie::with('genres', 'directors')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); + $tv = TmdbTv::with('genres', 'creators')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); $groups = $groups->through(function ($group) use ($movies, $tv) { switch ($group->meta) { case 'movie': - $group->movie = $movies[$group->movie_id] ?? null; + $group->movie = $movies[$group->tmdb_movie_id] ?? null; break; case 'tv': - $group->tv = $tv[$group->tv_id] ?? null; + $group->tv = $tv[$group->tmdb_tv_id] ?? null; break; } diff --git a/app/Http/Requests/StoreTorrentRequest.php b/app/Http/Requests/StoreTorrentRequest.php index 2bafa55b5..5c5bf6b6a 100644 --- a/app/Http/Requests/StoreTorrentRequest.php +++ b/app/Http/Requests/StoreTorrentRequest.php @@ -159,7 +159,7 @@ class StoreTorrentRequest extends FormRequest Rule::in([0]), ]), ], - 'movie_id' => [ + 'tmdb_movie_id' => [ Rule::when($category->movie_meta, [ 'required', 'decimal:0', @@ -170,7 +170,7 @@ class StoreTorrentRequest extends FormRequest 'exclude', ]), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ Rule::when($category->tv_meta, [ 'required', 'decimal:0', @@ -262,12 +262,12 @@ class StoreTorrentRequest extends FormRequest public function messages(): array { return [ - 'igdb.in' => 'The IGDB ID must be 0 if the media doesn\'t exist on IGDB or you\'re not uploading a game.', - 'movie_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not uploading a tv show or movie.', - 'tv_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not uploading a tv show or movie.', - 'imdb.in' => 'The IMDB ID must be 0 if the media doesn\'t exist on IMDB or you\'re not uploading a tv show or movie.', - 'tvdb.in' => 'The TVDB ID must be 0 if the media doesn\'t exist on TVDB or you\'re not uploading a tv show.', - 'mal.in' => 'The MAL ID must be 0 if the media doesn\'t exist on MAL or you\'re not uploading a tv or movie.', + 'igdb.in' => 'The IGDB ID must be 0 if the media doesn\'t exist on IGDB or you\'re not uploading a game.', + 'tmdb_movie_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not uploading a tv show or movie.', + 'tmdb_tv_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not uploading a tv show or movie.', + 'imdb.in' => 'The IMDB ID must be 0 if the media doesn\'t exist on IMDB or you\'re not uploading a tv show or movie.', + 'tvdb.in' => 'The TVDB ID must be 0 if the media doesn\'t exist on TVDB or you\'re not uploading a tv show.', + 'mal.in' => 'The MAL ID must be 0 if the media doesn\'t exist on MAL or you\'re not uploading a tv or movie.', ]; } } diff --git a/app/Http/Requests/StoreTorrentRequestRequest.php b/app/Http/Requests/StoreTorrentRequestRequest.php index d9a8cabb1..8ad0c39ce 100644 --- a/app/Http/Requests/StoreTorrentRequestRequest.php +++ b/app/Http/Requests/StoreTorrentRequestRequest.php @@ -65,7 +65,7 @@ class StoreTorrentRequestRequest extends FormRequest Rule::in([0]), ]), ], - 'movie_id' => [ + 'tmdb_movie_id' => [ Rule::when($category->movie_meta, [ 'required', 'decimal:0', @@ -75,7 +75,7 @@ class StoreTorrentRequestRequest extends FormRequest Rule::in([0]), ]), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ Rule::when($category->tv_meta, [ 'required', 'decimal:0', @@ -142,13 +142,13 @@ class StoreTorrentRequestRequest extends FormRequest public function messages(): array { return [ - 'igdb.in' => 'The IGDB ID must be 0 if the media doesn\'t exist on IGDB or you\'re not requesting a game.', - 'movie_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not requesting a tv show or movie.', - 'tv_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not requesting a tv show or movie.', - 'imdb.in' => 'The IMDB ID must be 0 if the media doesn\'t exist on IMDB or you\'re not requesting a tv show or movie.', - 'tvdb.in' => 'The TVDB ID must be 0 if the media doesn\'t exist on TVDB or you\'re not requesting a tv show.', - 'mal.in' => 'The MAL ID must be 0 if the media doesn\'t exist on MAL or you\'re not requesting a tv or movie.', - 'bounty.max' => 'You do not have enough BON to make this request.', + 'igdb.in' => 'The IGDB ID must be 0 if the media doesn\'t exist on IGDB or you\'re not requesting a game.', + 'tmdb_movie_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not requesting a tv show or movie.', + 'tmdb_tv_id.in' => 'The TMDB ID must be 0 if the media doesn\'t exist on TMDB or you\'re not requesting a tv show or movie.', + 'imdb.in' => 'The IMDB ID must be 0 if the media doesn\'t exist on IMDB or you\'re not requesting a tv show or movie.', + 'tvdb.in' => 'The TVDB ID must be 0 if the media doesn\'t exist on TVDB or you\'re not requesting a tv show.', + 'mal.in' => 'The MAL ID must be 0 if the media doesn\'t exist on MAL or you\'re not requesting a tv or movie.', + 'bounty.max' => 'You do not have enough BON to make this request.', ]; } } diff --git a/app/Http/Requests/StoreWishRequest.php b/app/Http/Requests/StoreWishRequest.php index 32b0eb88a..afcf2d836 100644 --- a/app/Http/Requests/StoreWishRequest.php +++ b/app/Http/Requests/StoreWishRequest.php @@ -41,16 +41,16 @@ class StoreWishRequest extends FormRequest $user = auth()->user(); return [ - 'movie_id' => [ + 'tmdb_movie_id' => [ 'required_if:meta,movie', - 'required_without:tv_id', + 'required_without:tmdb_tv_id', 'decimal:0', 'min:1', Rule::unique('wishes')->where(fn (Builder $query) => $query->where('user_id', '=', $user->id)), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ 'required_if:meta,tv', - 'required_without:movie_id', + 'required_without:tmdb_movie_id', 'decimal:0', 'min:1', Rule::unique('wishes')->where(fn (Builder $query) => $query->where('user_id', '=', $user->id)), @@ -70,8 +70,8 @@ class StoreWishRequest extends FormRequest public function messages(): array { return [ - 'movie_id.unique' => 'You are already receiving notifications for this movie.', - 'tv_id.unique' => 'You are already receiving notifications for this tv.', + 'tmdb_movie_id.unique' => 'You are already receiving notifications for this movie.', + 'tmdb_tv_id.unique' => 'You are already receiving notifications for this tv.', ]; } } diff --git a/app/Http/Requests/UpdateTorrentRequest.php b/app/Http/Requests/UpdateTorrentRequest.php index f104aae74..ac9e1347d 100644 --- a/app/Http/Requests/UpdateTorrentRequest.php +++ b/app/Http/Requests/UpdateTorrentRequest.php @@ -109,7 +109,7 @@ class UpdateTorrentRequest extends FormRequest Rule::in([0]), ]), ], - 'movie_id' => [ + 'tmdb_movie_id' => [ Rule::when($category->movie_meta, [ 'required', 'decimal:0', @@ -119,7 +119,7 @@ class UpdateTorrentRequest extends FormRequest Rule::in([0]), ]), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ Rule::when($category->tv_meta, [ 'required', 'decimal:0', diff --git a/app/Http/Requests/UpdateTorrentRequestRequest.php b/app/Http/Requests/UpdateTorrentRequestRequest.php index 961be3efc..f52c5aec0 100644 --- a/app/Http/Requests/UpdateTorrentRequestRequest.php +++ b/app/Http/Requests/UpdateTorrentRequestRequest.php @@ -65,7 +65,7 @@ class UpdateTorrentRequestRequest extends FormRequest Rule::in([0]), ]), ], - 'movie_id' => [ + 'tmdb_movie_id' => [ Rule::when($category->movie_meta, [ 'required', 'decimal:0', @@ -75,7 +75,7 @@ class UpdateTorrentRequestRequest extends FormRequest Rule::in([0]), ]), ], - 'tv_id' => [ + 'tmdb_tv_id' => [ Rule::when($category->tv_meta, [ 'required', 'decimal:0', diff --git a/app/Http/Resources/TorrentResource.php b/app/Http/Resources/TorrentResource.php index 24f332fac..6bfc90114 100644 --- a/app/Http/Resources/TorrentResource.php +++ b/app/Http/Resources/TorrentResource.php @@ -65,7 +65,7 @@ class TorrentResource extends JsonResource 'seeders' => $this->seeders, 'leechers' => $this->leechers, 'times_completed' => $this->times_completed, - 'tmdb_id' => $this->movie_id ?? $this->tv_id, + 'tmdb_id' => $this->tmdb_movie_id ?? $this->tmdb_tv_id, 'imdb_id' => $this->imdb, 'tvdb_id' => $this->tvdb, 'mal_id' => $this->mal, diff --git a/app/Jobs/ProcessMovieJob.php b/app/Jobs/ProcessMovieJob.php index 2575c47b7..ba25d8892 100644 --- a/app/Jobs/ProcessMovieJob.php +++ b/app/Jobs/ProcessMovieJob.php @@ -16,13 +16,13 @@ declare(strict_types=1); namespace App\Jobs; -use App\Models\Collection; -use App\Models\Company; -use App\Models\Credit; -use App\Models\Genre; -use App\Models\Movie; -use App\Models\Person; -use App\Models\Recommendation; +use App\Models\TmdbCollection; +use App\Models\TmdbCompany; +use App\Models\TmdbCredit; +use App\Models\TmdbGenre; +use App\Models\TmdbMovie; +use App\Models\TmdbPerson; +use App\Models\TmdbRecommendation; use App\Models\Torrent; use App\Services\Tmdb\Client; use Illuminate\Bus\Queueable; @@ -62,11 +62,11 @@ class ProcessMovieJob implements ShouldQueue $movieScraper = new Client\Movie($this->id); - $movie = Movie::updateOrCreate(['id' => $this->id], $movieScraper->getMovie()); + $movie = TmdbMovie::updateOrCreate(['id' => $this->id], $movieScraper->getMovie()); // Genres - Genre::upsert($movieScraper->getGenres(), 'id'); + TmdbGenre::upsert($movieScraper->getGenres(), 'id'); $movie->genres()->sync(array_unique(array_column($movieScraper->getGenres(), 'id'))); // Companies @@ -77,7 +77,7 @@ class ProcessMovieJob implements ShouldQueue $companies[] = (new Client\Company($company['id']))->getCompany(); } - Company::upsert($companies, 'id'); + TmdbCompany::upsert($companies, 'id'); $movie->companies()->sync(array_unique(array_column($companies, 'id'))); // Collection @@ -85,7 +85,7 @@ class ProcessMovieJob implements ShouldQueue if ($movieScraper->data['belongs_to_collection'] !== null) { $collection = (new Client\Collection($movieScraper->data['belongs_to_collection']['id']))->getCollection(); - Collection::upsert($collection, 'id'); + TmdbCollection::upsert($collection, 'id'); $movie->collection()->sync([$collection['id']]); } @@ -94,20 +94,20 @@ class ProcessMovieJob implements ShouldQueue $credits = $movieScraper->getCredits(); $people = []; - foreach (array_unique(array_column($credits, 'person_id')) as $person_id) { + foreach (array_unique(array_column($credits, 'tmdb_person_id')) as $person_id) { $people[] = (new Client\Person($person_id))->getPerson(); } - Person::upsert($people, 'id'); - Credit::where('movie_id', '=', $this->id)->delete(); - Credit::upsert($credits, ['person_id', 'movie_id', 'tv_id', 'occupation_id', 'character']); + TmdbPerson::upsert($people, 'id'); + TmdbCredit::where('tmdb_movie_id', '=', $this->id)->delete(); + TmdbCredit::upsert($credits, ['tmdb_person_id', 'tmdb_movie_id', 'tmdb_tv_id', 'occupation_id', 'character']); // Recommendations - Recommendation::upsert($movieScraper->getRecommendations(), ['recommendation_movie_id', 'movie_id']); + TmdbRecommendation::upsert($movieScraper->getRecommendations(), ['recommended_tmdb_movie_id', 'tmdb_movie_id']); Torrent::query() - ->where('movie_id', '=', $this->id) + ->where('tmdb_movie_id', '=', $this->id) ->whereRelation('category', 'movie_meta', '=', true) ->searchable(); } diff --git a/app/Jobs/ProcessTvJob.php b/app/Jobs/ProcessTvJob.php index 9457ebd94..92dff5fce 100644 --- a/app/Jobs/ProcessTvJob.php +++ b/app/Jobs/ProcessTvJob.php @@ -16,16 +16,16 @@ declare(strict_types=1); namespace App\Jobs; -use App\Models\Company; -use App\Models\Credit; -use App\Models\Episode; -use App\Models\Genre; -use App\Models\Network; -use App\Models\Person; -use App\Models\Recommendation; -use App\Models\Season; +use App\Models\TmdbCompany; +use App\Models\TmdbCredit; +use App\Models\TmdbEpisode; +use App\Models\TmdbGenre; +use App\Models\TmdbNetwork; +use App\Models\TmdbPerson; +use App\Models\TmdbRecommendation; +use App\Models\TmdbSeason; use App\Models\Torrent; -use App\Models\Tv; +use App\Models\TmdbTv; use App\Services\Tmdb\Client; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -64,7 +64,7 @@ class ProcessTvJob implements ShouldQueue $tvScraper = new Client\TV($this->id); - $tv = Tv::updateOrCreate(['id' => $this->id], $tvScraper->getTv()); + $tv = TmdbTv::updateOrCreate(['id' => $this->id], $tvScraper->getTv()); // Companies @@ -74,7 +74,7 @@ class ProcessTvJob implements ShouldQueue $companies[] = (new Client\Company($company['id']))->getCompany(); } - Company::upsert($companies, 'id'); + TmdbCompany::upsert($companies, 'id'); $tv->companies()->sync(array_unique(array_column($companies, 'id'))); // Networks @@ -85,12 +85,12 @@ class ProcessTvJob implements ShouldQueue $networks[] = (new Client\Network($network['id']))->getNetwork(); } - Network::upsert($networks, 'id'); + TmdbNetwork::upsert($networks, 'id'); $tv->networks()->sync(array_unique(array_column($networks, 'id'))); // Genres - Genre::upsert($tvScraper->getGenres(), 'id'); + TmdbGenre::upsert($tvScraper->getGenres(), 'id'); $tv->genres()->sync(array_unique(array_column($tvScraper->getGenres(), 'id'))); // People @@ -98,13 +98,13 @@ class ProcessTvJob implements ShouldQueue $credits = $tvScraper->getCredits(); $people = []; - foreach (array_unique(array_column($credits, 'person_id')) as $person_id) { + foreach (array_unique(array_column($credits, 'tmdb_person_id')) as $person_id) { $people[] = (new Client\Person($person_id))->getPerson(); } - Person::upsert($people, 'id'); - Credit::where('tv_id', '=', $this->id)->delete(); - Credit::upsert($credits, ['person_id', 'movie_id', 'tv_id', 'occupation_id', 'character']); + TmdbPerson::upsert($people, 'id'); + TmdbCredit::where('tmdb_tv_id', '=', $this->id)->delete(); + TmdbCredit::upsert($credits, ['tmdb_person_id', 'tmdb_movie_id', 'tmdb_tv_id', 'occupation_id', 'character']); // Seasons and episodes @@ -118,15 +118,15 @@ class ProcessTvJob implements ShouldQueue array_push($episodes, ...$seasonScraper->getEpisodes()); } - Season::upsert($seasons, 'id'); - Episode::upsert($episodes, 'id'); + TmdbSeason::upsert($seasons, 'id'); + TmdbEpisode::upsert($episodes, 'id'); // Recommendations - Recommendation::upsert($tvScraper->getRecommendations(), ['recommendation_tv_id', 'tv_id']); + TmdbRecommendation::upsert($tvScraper->getRecommendations(), ['recommended_tmdb_tv_id', 'tmdb_tv_id']); Torrent::query() - ->where('tv_id', '=', $this->id) + ->where('tmdb_tv_id', '=', $this->id) ->whereRelation('category', 'tv_meta', '=', true) ->searchable(); } diff --git a/app/Models/GuestStar.php b/app/Models/GuestStar.php index 96b70e09e..2cdc0440b 100644 --- a/app/Models/GuestStar.php +++ b/app/Models/GuestStar.php @@ -47,13 +47,13 @@ class GuestStar extends Model public $timestamps = false; - public $table = 'people'; + public $table = 'tmdb_people'; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function episode(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Episode::class, 'episode_guest_star', 'episode_id', 'person_id'); + return $this->belongsToMany(TmdbEpisode::class, 'episode_guest_star', 'tmdb_episode_id', 'tmdb_person_id'); } } diff --git a/app/Models/Occupation.php b/app/Models/Occupation.php index bfc4200fc..2a269a655 100644 --- a/app/Models/Occupation.php +++ b/app/Models/Occupation.php @@ -42,18 +42,18 @@ class Occupation extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Person::class, 'credits'); + return $this->belongsToMany(TmdbPerson::class, 'tmdb_credits'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Credit::class); + return $this->hasMany(TmdbCredit::class); } } diff --git a/app/Models/Collection.php b/app/Models/TmdbCollection.php similarity index 86% rename from app/Models/Collection.php rename to app/Models/TmdbCollection.php index 36177ba7e..d5059d90d 100644 --- a/app/Models/Collection.php +++ b/app/Models/TmdbCollection.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Collection. + * App\Models\TmdbCollection. * * @property int $id * @property string $name @@ -32,9 +32,9 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $created_at * @property string|null $updated_at */ -class Collection extends Model +class TmdbCollection extends Model { - /** @use HasFactory<\Database\Factories\CollectionFactory> */ + /** @use HasFactory<\Database\Factories\TmdbCollectionFactory> */ use HasFactory; protected $guarded = []; @@ -50,10 +50,10 @@ class Collection extends Model } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class); + return $this->belongsToMany(TmdbMovie::class); } } diff --git a/app/Models/Company.php b/app/Models/TmdbCompany.php similarity index 72% rename from app/Models/Company.php rename to app/Models/TmdbCompany.php index 81d953a6c..e721b085c 100644 --- a/app/Models/Company.php +++ b/app/Models/TmdbCompany.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Company. + * App\Models\TmdbCompany. * * @property int $id * @property string $name @@ -30,9 +30,9 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $logo * @property string|null $origin_country */ -class Company extends Model +class TmdbCompany extends Model { - /** @use HasFactory<\Database\Factories\CompanyFactory> */ + /** @use HasFactory<\Database\Factories\TmdbCompanyFactory> */ use HasFactory; protected $guarded = []; @@ -40,19 +40,19 @@ class Company extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class); + return $this->belongsToMany(TmdbMovie::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class); + return $this->belongsToMany(TmdbTv::class); } /** @@ -60,7 +60,7 @@ class Company extends Model */ public function movieTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Torrent::class, 'company_movie', 'movie_id', 'company_id', 'id', 'movie_id')->whereRelation('category', 'movie_meta', '=', true); + return $this->belongsToMany(Torrent::class, 'tmdb_company_tmdb_movie', 'tmdb_movie_id', 'tmdb_company_id', 'id', 'tmdb_movie_id')->whereRelation('category', 'movie_meta', '=', true); } /** @@ -68,6 +68,6 @@ class Company extends Model */ public function tvTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Torrent::class, 'company_tv', 'tv_id', 'company_id', 'id', 'tv_id')->whereRelation('category', 'tv_meta', '=', true); + return $this->belongsToMany(Torrent::class, 'tmdb_company_tmdb_tv', 'tmdb_tv_id', 'tmdb_company_id', 'id', 'tmdb_tv_id')->whereRelation('category', 'tv_meta', '=', true); } } diff --git a/app/Models/Credit.php b/app/Models/TmdbCredit.php similarity index 76% rename from app/Models/Credit.php rename to app/Models/TmdbCredit.php index 3b5b2d828..be5ad74f7 100644 --- a/app/Models/Credit.php +++ b/app/Models/TmdbCredit.php @@ -20,19 +20,19 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Credit. + * App\Models\TmdbCredit. * * @property int $id - * @property int $person_id - * @property int|null $movie_id - * @property int|null $tv_id + * @property int $tmdb_person_id + * @property int|null $tmdb_movie_id + * @property int|null $tmdb_tv_id * @property int $occupation_id * @property int|null $order * @property string|null $character */ -class Credit extends Model +class TmdbCredit extends Model { - /** @use HasFactory<\Database\Factories\CreditFactory> */ + /** @use HasFactory<\Database\Factories\TmdbCreditFactory> */ use HasFactory; /** @@ -51,26 +51,26 @@ class Credit extends Model } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function person(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Person::class); + return $this->belongsTo(TmdbPerson::class, 'tmdb_person_id'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Tv::class); + return $this->belongsTo(TmdbTv::class, 'tmdb_tv_id'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Movie::class); + return $this->belongsTo(TmdbMovie::class, 'tmdb_movie_id'); } } diff --git a/app/Models/Episode.php b/app/Models/TmdbEpisode.php similarity index 80% rename from app/Models/Episode.php rename to app/Models/TmdbEpisode.php index 31b70a703..495ca7fcd 100644 --- a/app/Models/Episode.php +++ b/app/Models/TmdbEpisode.php @@ -20,16 +20,16 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Episode. + * App\Models\TmdbEpisode. * * @property int $id * @property string $name * @property string|null $overview * @property string|null $production_code * @property int $season_number - * @property int $season_id + * @property int $tmdb_season_id * @property string|null $still - * @property int $tv_id + * @property int $tmdb_tv_id * @property string|null $type * @property string|null $vote_average * @property int|null $vote_count @@ -38,9 +38,9 @@ use Illuminate\Database\Eloquent\Model; * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at */ -class Episode extends Model +class TmdbEpisode extends Model { - /** @use HasFactory<\Database\Factories\EpisodeFactory> */ + /** @use HasFactory<\Database\Factories\TmdbEpisodeFactory> */ use HasFactory; protected $guarded = []; @@ -50,12 +50,12 @@ class Episode extends Model protected string $orderDirection = 'ASC'; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function season(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Season::class) - ->oldest('season_id') - ->oldest('episode_id'); + return $this->belongsTo(TmdbSeason::class) + ->oldest('tmdb_season_id') + ->oldest('tmdb_episode_id'); } } diff --git a/app/Models/Genre.php b/app/Models/TmdbGenre.php similarity index 79% rename from app/Models/Genre.php rename to app/Models/TmdbGenre.php index d51a56cf9..6067883e2 100644 --- a/app/Models/Genre.php +++ b/app/Models/TmdbGenre.php @@ -20,14 +20,14 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Genre. + * App\Models\TmdbGenre. * * @property int $id * @property string $name */ -class Genre extends Model +class TmdbGenre extends Model { - /** @use HasFactory<\Database\Factories\GenreFactory> */ + /** @use HasFactory<\Database\Factories\TmdbGenreFactory> */ use HasFactory; protected $guarded = []; @@ -35,18 +35,18 @@ class Genre extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class); + return $this->belongsToMany(TmdbMovie::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class); + return $this->belongsToMany(TmdbTv::class); } } diff --git a/app/Models/Movie.php b/app/Models/TmdbMovie.php similarity index 81% rename from app/Models/Movie.php rename to app/Models/TmdbMovie.php index 2b10cdf67..d29e484da 100644 --- a/app/Models/Movie.php +++ b/app/Models/TmdbMovie.php @@ -21,7 +21,7 @@ use App\Enums\Occupation; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Movie. + * App\Models\TmdbMovie. * * @property int $id * @property string|null $tmdb_id @@ -48,9 +48,9 @@ use Illuminate\Database\Eloquent\Model; * @property \Illuminate\Support\Carbon|null $updated_at * @property string|null $trailer */ -class Movie extends Model +class TmdbMovie extends Model { - /** @use HasFactory<\Database\Factories\MovieFactory> */ + /** @use HasFactory<\Database\Factories\TmdbMovieFactory> */ use HasFactory; protected $guarded = []; @@ -68,68 +68,68 @@ class Movie extends Model } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function genres(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Genre::class); + return $this->belongsToMany(TmdbGenre::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Person::class, 'credits'); + return $this->belongsToMany(TmdbPerson::class, 'tmdb_credits'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Credit::class); + return $this->hasMany(TmdbCredit::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function directors(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Person::class, 'credits') + return $this->belongsToMany(TmdbPerson::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::DIRECTOR->value); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Company::class); + return $this->belongsToMany(TmdbCompany::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function collection(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Collection::class)->take(1); + return $this->belongsToMany(TmdbCollection::class)->take(1); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function recommendations(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Recommendation::class, 'movie_id', 'id'); + return $this->hasMany(TmdbRecommendation::class, 'tmdb_movie_id', 'id'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function recommendedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(__CLASS__, Recommendation::class, 'movie_id', 'recommendation_movie_id', 'id', 'id'); + return $this->belongsToMany(__CLASS__, TmdbRecommendation::class, 'tmdb_movie_id', 'recommended_tmdb_movie_id', 'id', 'id'); } /** diff --git a/app/Models/Network.php b/app/Models/TmdbNetwork.php similarity index 76% rename from app/Models/Network.php rename to app/Models/TmdbNetwork.php index 78614a88c..6dafc75fd 100644 --- a/app/Models/Network.php +++ b/app/Models/TmdbNetwork.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Network. + * App\Models\TmdbNetwork. * * @property int $id * @property string $name @@ -30,9 +30,9 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $headquarters * @property string|null $origin_country */ -class Network extends Model +class TmdbNetwork extends Model { - /** @use HasFactory<\Database\Factories\NetworkFactory> */ + /** @use HasFactory<\Database\Factories\TmdbNetworkFactory> */ use HasFactory; protected $guarded = []; @@ -40,19 +40,19 @@ class Network extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class); + return $this->belongsToMany(TmdbTv::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class); + return $this->belongsToMany(TmdbMovie::class); } /** @@ -60,6 +60,6 @@ class Network extends Model */ public function tvTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Torrent::class, 'network_tv', 'tv_id', 'network_id', 'id', 'tv_id')->whereRelation('category', 'tv_meta', '=', true); + return $this->belongsToMany(Torrent::class, 'tmdb_network_tmdb_tv', 'tmdb_tv_id', 'tmdb_network_id', 'id', 'tmdb_tv_id')->whereRelation('category', 'tv_meta', '=', true); } } diff --git a/app/Models/Person.php b/app/Models/TmdbPerson.php similarity index 79% rename from app/Models/Person.php rename to app/Models/TmdbPerson.php index d787754d6..a884dc9e2 100644 --- a/app/Models/Person.php +++ b/app/Models/TmdbPerson.php @@ -21,7 +21,7 @@ use App\Enums\Occupation; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Person. + * App\Models\TmdbPerson. * * @property int $id * @property string $name @@ -39,9 +39,9 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $gender * @property string|null $homepage */ -class Person extends Model +class TmdbPerson extends Model { - /** @use HasFactory<\Database\Factories\PersonFactory> */ + /** @use HasFactory<\Database\Factories\TmdbPersonFactory> */ use HasFactory; protected $guarded = []; @@ -49,237 +49,237 @@ class Person extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Credit::class); + return $this->hasMany(TmdbCredit::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function createdTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::CREATOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function directedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::DIRECTOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function writtenTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::WRITER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function producedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::PRODUCER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function composedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::COMPOSER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function cinematographedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::CINEMATOGRAPHER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function editedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::EDITOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function productionDesignedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::PRODUCTION_DESIGNER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function artDirectedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::ART_DIRECTOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function actedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Tv::class, 'credits') + return $this->belongsToMany(TmdbTv::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::ACTOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function directedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::DIRECTOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function writtenMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::WRITER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function producedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::PRODUCER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function composedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::COMPOSER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function cinematographedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::CINEMATOGRAPHER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function editedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::EDITOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function productionDesignedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::PRODUCTION_DESIGNER) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function artDirectedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::ART_DIRECTOR) ->withPivot('character', 'occupation_id') ->as('credit'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function actedMovies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Movie::class, 'credits') + return $this->belongsToMany(TmdbMovie::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::ACTOR) ->withPivot('character', 'occupation_id') ->as('credit'); diff --git a/app/Models/Recommendation.php b/app/Models/TmdbRecommendation.php similarity index 71% rename from app/Models/Recommendation.php rename to app/Models/TmdbRecommendation.php index c668320a3..f446f19ee 100644 --- a/app/Models/Recommendation.php +++ b/app/Models/TmdbRecommendation.php @@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Recommendation. + * App\Models\TmdbRecommendation. * * @property int $id * @property string $title @@ -28,14 +28,14 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $vote_average * @property string|null $release_date * @property string|null $first_air_date - * @property int|null $movie_id - * @property int|null $recommendation_movie_id - * @property int|null $tv_id - * @property int|null $recommendation_tv_id + * @property int|null $tmdb_movie_id + * @property int|null $recommended_tmdb_movie_id + * @property int|null $tmdb_tv_id + * @property int|null $recommended_tmdb_tv_id */ -class Recommendation extends Model +class TmdbRecommendation extends Model { - /** @use HasFactory<\Database\Factories\RecommendationFactory> */ + /** @use HasFactory<\Database\Factories\TmdbRecommendationFactory> */ use HasFactory; protected $guarded = []; @@ -43,18 +43,18 @@ class Recommendation extends Model public $timestamps = false; /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Movie::class); + return $this->belongsTo(TmdbMovie::class, 'tmdb_movie_id'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Tv::class); + return $this->belongsTo(TmdbTv::class, 'tmdb_tv_id'); } } diff --git a/app/Models/Season.php b/app/Models/TmdbSeason.php similarity index 75% rename from app/Models/Season.php rename to app/Models/TmdbSeason.php index 523583438..e9fa6248c 100644 --- a/app/Models/Season.php +++ b/app/Models/TmdbSeason.php @@ -20,10 +20,10 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Season. + * App\Models\TmdbSeason. * * @property int $id - * @property int $tv_id + * @property int $tmdb_tv_id * @property int $season_number * @property string|null $name * @property string|null $overview @@ -32,9 +32,9 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $created_at * @property string|null $updated_at */ -class Season extends Model +class TmdbSeason extends Model { - /** @use HasFactory<\Database\Factories\SeasonFactory> */ + /** @use HasFactory<\Database\Factories\TmdbSeasonFactory> */ use HasFactory; protected $guarded = []; @@ -48,23 +48,23 @@ class Season extends Model */ public function torrents(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Torrent::class, 'tv_id', 'tv_id')->whereRelation('category', 'tv_meta', '=', true); + return $this->hasMany(Torrent::class, 'tmdb_tv_id', 'tmdb_tv_id')->whereRelation('category', 'tv_meta', '=', true); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Tv::class); + return $this->belongsTo(TmdbTv::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function episodes(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Episode::class) + return $this->hasMany(TmdbEpisode::class) ->oldest('episode_number'); } } diff --git a/app/Models/Tv.php b/app/Models/TmdbTv.php similarity index 80% rename from app/Models/Tv.php rename to app/Models/TmdbTv.php index d7f13789b..6d7971a8a 100644 --- a/app/Models/Tv.php +++ b/app/Models/TmdbTv.php @@ -21,7 +21,7 @@ use App\Enums\Occupation; use Illuminate\Database\Eloquent\Model; /** - * App\Models\Tv. + * App\Models\TmdbTv. * * @property int $id * @property string|null $tmdb_id @@ -54,14 +54,14 @@ use Illuminate\Database\Eloquent\Model; * @property \Illuminate\Support\Carbon|null $updated_at * @property string|null $trailer */ -class Tv extends Model +class TmdbTv extends Model { - /** @use HasFactory<\Database\Factories\TvFactory> */ + /** @use HasFactory<\Database\Factories\TmdbTvFactory> */ use HasFactory; protected $guarded = []; - public $table = 'tv'; + public $table = 'tmdb_tv'; protected $hidden = ['created_at', 'updated_at']; @@ -89,77 +89,77 @@ class Tv extends Model } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function seasons(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Season::class) + return $this->hasMany(TmdbSeason::class) ->oldest('season_number'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Person::class, 'credits'); + return $this->belongsToMany(TmdbPerson::class, 'tmdb_credits'); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Credit::class); + return $this->hasMany(TmdbCredit::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function creators(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Person::class, 'credits') + return $this->belongsToMany(TmdbPerson::class, 'tmdb_credits') ->wherePivot('occupation_id', '=', Occupation::CREATOR->value); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function genres(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Genre::class); + return $this->belongsToMany(TmdbGenre::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function networks(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Network::class); + return $this->belongsToMany(TmdbNetwork::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(Company::class); + return $this->belongsToMany(TmdbCompany::class); } /** - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function recommendations(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Recommendation::class, 'tv_id', 'id'); + return $this->hasMany(TmdbRecommendation::class, 'tmdb_tv_id', 'id'); } /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function recommendedTv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { - return $this->belongsToMany(__CLASS__, Recommendation::class, 'tv_id', 'recommendation_tv_id', 'id', 'id'); + return $this->belongsToMany(__CLASS__, TmdbRecommendation::class, 'tmdb_tv_id', 'recommended_tmdb_tv_id', 'id', 'id'); } /** diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 7e2067aed..bb3253321 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -50,8 +50,8 @@ use Laravel\Scout\Searchable; * @property int $user_id * @property int $imdb * @property int $tvdb - * @property int|null $movie_id - * @property int|null $tv_id + * @property int|null $tmdb_movie_id + * @property int|null $tmdb_tv_id * @property int $mal * @property int $igdb * @property int|null $season_number @@ -96,8 +96,8 @@ class Torrent extends Model * Get the attributes that should be cast. * * @return array{ - * movie_id: 'int', - * tv_id: 'int', + * tmdb_movie_id: 'int', + * tmdb_tv_id: 'int', * igdb: 'int', * status: class-string, * bumped_at: 'datetime', @@ -114,8 +114,8 @@ class Torrent extends Model protected function casts(): array { return [ - 'movie_id' => 'int', - 'tv_id' => 'int', + 'tmdb_movie_id' => 'int', + 'tmdb_tv_id' => 'int', 'igdb' => 'int', 'bumped_at' => 'datetime', 'fl_until' => 'datetime', @@ -164,8 +164,8 @@ class Torrent extends Model torrents.user_id, torrents.imdb, torrents.tvdb, - torrents.movie_id, - torrents.tv_id, + torrents.tmdb_movie_id, + torrents.tmdb_tv_id, torrents.mal, torrents.igdb, torrents.season_number, @@ -287,9 +287,9 @@ class Torrent extends Model ) AS json_resolution, ( SELECT vote_average - FROM movies + FROM tmdb_movies WHERE - torrents.movie_id = movies.id + torrents.tmdb_movie_id = tmdb_movies.id AND torrents.category_id in ( SELECT id FROM categories @@ -297,9 +297,9 @@ class Torrent extends Model ) UNION SELECT vote_average - FROM tv + FROM tmdb_tv WHERE - torrents.tv_id = tv.id + torrents.tmdb_tv_id = tmdb_tv.id AND torrents.category_id in ( SELECT id FROM categories @@ -319,43 +319,43 @@ class Torrent extends Model ) AS featured, ( SELECT JSON_OBJECT( - 'id', movies.id, - 'name', movies.title, - 'year', YEAR(movies.release_date), - 'poster', movies.poster, - 'original_language', movies.original_language, - 'adult', movies.adult != 0, - 'rating', movies.vote_average, + 'id', tmdb_movies.id, + 'name', tmdb_movies.title, + 'year', YEAR(tmdb_movies.release_date), + 'poster', tmdb_movies.poster, + 'original_language', tmdb_movies.original_language, + 'adult', tmdb_movies.adult != 0, + 'rating', tmdb_movies.vote_average, 'companies', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( - 'id', companies.id, - 'name', companies.name + 'id', tmdb_companies.id, + 'name', tmdb_companies.name )), JSON_ARRAY()) - FROM companies - WHERE companies.id IN ( - SELECT company_id - FROM company_movie - WHERE company_movie.movie_id = torrents.movie_id + FROM tmdb_companies + WHERE tmdb_companies.id IN ( + SELECT tmdb_company_id + FROM tmdb_company_tmdb_movie + WHERE tmdb_company_tmdb_movie.tmdb_movie_id = torrents.tmdb_movie_id ) ), 'genres', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( - 'id', genres.id, - 'name', genres.name + 'id', tmdb_genres.id, + 'name', tmdb_genres.name )), JSON_ARRAY()) - FROM genres - WHERE genres.id IN ( - SELECT genre_id - FROM genre_movie - WHERE genre_movie.movie_id = torrents.movie_id + FROM tmdb_genres + WHERE tmdb_genres.id IN ( + SELECT tmdb_genre_id + FROM tmdb_genre_tmdb_movie + WHERE tmdb_genre_tmdb_movie.tmdb_movie_id = torrents.tmdb_movie_id ) ), 'collection', ( SELECT JSON_OBJECT( - 'id', collection_movie.collection_id + 'id', tmdb_collection_tmdb_movie.tmdb_collection_id ) - FROM collection_movie - WHERE movies.id = collection_movie.movie_id + FROM tmdb_collection_tmdb_movie + WHERE tmdb_movies.id = tmdb_collection_tmdb_movie.tmdb_movie_id LIMIT 1 ), 'wishes', ( @@ -363,60 +363,60 @@ class Torrent extends Model 'user_id', wishes.user_id )), JSON_ARRAY()) FROM wishes - WHERE wishes.movie_id = movies.id + WHERE wishes.tmdb_movie_id = tmdb_movies.id ) ) - FROM movies - WHERE torrents.movie_id = movies.id + FROM tmdb_movies + WHERE torrents.tmdb_movie_id = tmdb_movies.id AND torrents.category_id in ( SELECT id FROM categories WHERE movie_meta = 1 ) LIMIT 1 - ) AS json_movie, + ) AS json_tmdb_movie, ( SELECT JSON_OBJECT( - 'id', tv.id, - 'name', tv.name, - 'year', YEAR(tv.first_air_date), - 'poster', tv.poster, - 'original_language', tv.original_language, - 'rating', tv.vote_average, + 'id', tmdb_tv.id, + 'name', tmdb_tv.name, + 'year', YEAR(tmdb_tv.first_air_date), + 'poster', tmdb_tv.poster, + 'original_language', tmdb_tv.original_language, + 'rating', tmdb_tv.vote_average, 'companies', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( - 'id', companies.id, - 'name', companies.name + 'id', tmdb_companies.id, + 'name', tmdb_companies.name )), JSON_ARRAY()) - FROM companies - WHERE companies.id IN ( - SELECT company_id - FROM company_tv - WHERE company_tv.tv_id = torrents.tv_id + FROM tmdb_companies + WHERE tmdb_companies.id IN ( + SELECT tmdb_company_id + FROM tmdb_company_tmdb_tv + WHERE tmdb_company_tmdb_tv.tmdb_tv_id = torrents.tmdb_tv_id ) ), 'genres', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( - 'id', genres.id, - 'name', genres.name + 'id', tmdb_genres.id, + 'name', tmdb_genres.name )), JSON_ARRAY()) - FROM genres - WHERE genres.id IN ( - SELECT genre_id - FROM genre_tv - WHERE genre_tv.tv_id = torrents.tv_id + FROM tmdb_genres + WHERE tmdb_genres.id IN ( + SELECT tmdb_genre_id + FROM tmdb_genre_tmdb_tv + WHERE tmdb_genre_tmdb_tv.tmdb_tv_id = torrents.tmdb_tv_id ) ), 'networks', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( - 'id', networks.id, - 'name', networks.name + 'id', tmdb_networks.id, + 'name', tmdb_networks.name )), JSON_ARRAY()) - FROM networks - WHERE networks.id IN ( - SELECT network_id - FROM network_tv - WHERE network_tv.tv_id = torrents.tv_id + FROM tmdb_networks + WHERE tmdb_networks.id IN ( + SELECT tmdb_network_id + FROM tmdb_network_tmdb_tv + WHERE tmdb_network_tmdb_tv.tmdb_tv_id = torrents.tmdb_tv_id ) ), 'wishes', ( @@ -424,18 +424,18 @@ class Torrent extends Model 'user_id', wishes.user_id )), JSON_ARRAY()) FROM wishes - WHERE wishes.tv_id = tv.id + WHERE wishes.tmdb_tv_id = tmdb_tv.id ) ) - FROM tv - WHERE torrents.tv_id = tv.id + FROM tmdb_tv + WHERE torrents.tmdb_tv_id = tmdb_tv.id AND torrents.category_id in ( SELECT id FROM categories WHERE tv_meta = 1 ) LIMIT 1 - ) AS json_tv, + ) AS json_tmdb_tv, ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( 'id', playlist_torrents.playlist_id @@ -544,21 +544,21 @@ class Torrent extends Model /** * Belongs To A Movie. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Movie::class); + return $this->belongsTo(TmdbMovie::class, 'tmdb_movie_id'); } /** * Belongs To A Tv. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Tv::class); + return $this->belongsTo(TmdbTv::class, 'tmdb_tv_id'); } /** @@ -841,8 +841,8 @@ class Torrent extends Model 'user_id', 'imdb', 'tvdb', - 'movie_id', - 'tv_id', + 'tmdb_movie_id', + 'tmdb_tv_id', 'mal', 'igdb', 'season_number', @@ -867,8 +867,8 @@ class Torrent extends Model 'json_type', 'json_category', 'json_resolution', - 'json_movie', - 'json_tv', + 'json_tmdb_movie', + 'json_tmdb_tv', 'json_playlists', 'json_freeleech_tokens', 'json_bookmarks', @@ -912,8 +912,8 @@ class Torrent extends Model 'user_id' => $torrent->user_id, 'imdb' => $torrent->imdb, 'tvdb' => $torrent->tvdb, - 'movie_id' => $torrent->movie_id, - 'tv_id' => $torrent->tv_id, + 'tmdb_movie_id' => $torrent->tmdb_movie_id, + 'tmdb_tv_id' => $torrent->tmdb_tv_id, 'mal' => $torrent->mal, 'igdb' => $torrent->igdb, 'season_number' => $torrent->season_number, @@ -938,8 +938,8 @@ class Torrent extends Model 'type' => json_decode($torrent->json_type ?? 'null'), 'category' => json_decode($torrent->json_category ?? 'null'), 'resolution' => json_decode($torrent->json_resolution ?? 'null'), - 'movie' => json_decode($torrent->json_movie ?? 'null'), - 'tv' => json_decode($torrent->json_tv ?? 'null'), + 'tmdb_movie' => json_decode($torrent->json_tmdb_movie ?? 'null'), + 'tmdb_tv' => json_decode($torrent->json_tmdb_tv ?? 'null'), 'playlists' => json_decode($torrent->json_playlists ?? '[]'), 'freeleech_tokens' => json_decode($torrent->json_freeleech_tokens ?? '[]'), 'bookmarks' => json_decode($torrent->json_bookmarks ?? '[]'), diff --git a/app/Models/TorrentRequest.php b/app/Models/TorrentRequest.php index e34e98f98..55d6f2003 100644 --- a/app/Models/TorrentRequest.php +++ b/app/Models/TorrentRequest.php @@ -28,8 +28,8 @@ use Illuminate\Database\Eloquent\Model; * @property int $category_id * @property int|null $imdb * @property int|null $tvdb - * @property int|null $movie_id - * @property int|null $tv_id + * @property int|null $tmdb_movie_id + * @property int|null $tmdb_tv_id * @property int|null $mal * @property int $igdb * @property string $description @@ -76,8 +76,8 @@ class TorrentRequest extends Model * @return array{ * filled_when: 'datetime', * approved_when: 'datetime', - * movie_id: 'int', - * tv_id: 'int', + * tmdb_movie_id: 'int', + * tmdb_tv_id: 'int', * igdb: 'int', * bounty: 'decimal:2', * anon: 'bool' @@ -88,8 +88,8 @@ class TorrentRequest extends Model return [ 'filled_when' => 'datetime', 'approved_when' => 'datetime', - 'movie_id' => 'int', - 'tv_id' => 'int', + 'tmdb_movie_id' => 'int', + 'tmdb_tv_id' => 'int', 'igdb' => 'int', 'bounty' => 'decimal:2', 'anon' => 'bool', @@ -178,21 +178,21 @@ class TorrentRequest extends Model /** * Belongs To A Movie. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Movie::class); + return $this->belongsTo(TmdbMovie::class, 'tmdb_movie_id'); } /** * Belongs To A Tv. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo { - return $this->belongsTo(Tv::class); + return $this->belongsTo(TmdbTv::class, 'tmdb_tv_id'); } /** diff --git a/app/Models/Wish.php b/app/Models/Wish.php index 46d445ed9..1bb4ad7ae 100644 --- a/app/Models/Wish.php +++ b/app/Models/Wish.php @@ -26,8 +26,8 @@ use Illuminate\Database\Eloquent\Model; * @property int $id * @property int $user_id * @property string $title - * @property int $movie_id - * @property int $tv_id + * @property int $tmdb_movie_id + * @property int $tmdb_tv_id * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at */ @@ -62,7 +62,7 @@ class Wish extends Model */ public function movieTorrents(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Torrent::class, 'movie_id', 'movie_id') + return $this->hasMany(Torrent::class, 'tmdb_movie_id', 'tmdb_movie_id') ->whereRelation('category', 'movie_meta', '=', true); } @@ -73,7 +73,7 @@ class Wish extends Model */ public function tvTorrents(): \Illuminate\Database\Eloquent\Relations\HasMany { - return $this->hasMany(Torrent::class, 'tv_id', 'tv_id') + return $this->hasMany(Torrent::class, 'tmdb_tv_id', 'tmdb_tv_id') ->whereRelation('category', 'tv_meta', '=', true); } } diff --git a/app/Notifications/NewCommentTag.php b/app/Notifications/NewCommentTag.php index 4f7ac9b3e..68c7f7e50 100644 --- a/app/Notifications/NewCommentTag.php +++ b/app/Notifications/NewCommentTag.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace App\Notifications; use App\Models\Article; -use App\Models\Collection; +use App\Models\TmdbCollection; use App\Models\Comment; use App\Models\Playlist; use App\Models\Ticket; @@ -35,7 +35,7 @@ class NewCommentTag extends Notification implements ShouldQueue /** * NewCommentTag Constructor. */ - public function __construct(public Torrent|TorrentRequest|Ticket|Playlist|Collection|Article $model, public Comment $comment) + public function __construct(public Torrent|TorrentRequest|Ticket|Playlist|TmdbCollection|Article $model, public Comment $comment) { } @@ -99,7 +99,7 @@ class NewCommentTag extends Notification implements ShouldQueue // If the sender's group ID is found in the "Block all notifications from the selected groups" array, // the expression will return false. return ! \in_array($this->comment->user->group_id, $notifiable->notification?->json_mention_groups ?? [], true); - case $this->model instanceof Collection: + case $this->model instanceof TmdbCollection: break; } @@ -137,7 +137,7 @@ class NewCommentTag extends Notification implements ShouldQueue 'body' => $username.' has tagged you in an comment on Playlist '.$this->model->name, 'url' => '/playlists/'.$this->model->id, ], - $this->model instanceof Collection => [ + $this->model instanceof TmdbCollection => [ 'title' => $title, 'body' => $username.' has tagged you in an comment on Collection '.$this->model->name, 'url' => '/mediahub/collections/'.$this->model->id, diff --git a/app/Services/Tmdb/Client/Movie.php b/app/Services/Tmdb/Client/Movie.php index e63fc03e7..f3b2a487c 100644 --- a/app/Services/Tmdb/Client/Movie.php +++ b/app/Services/Tmdb/Client/Movie.php @@ -346,8 +346,8 @@ class Movie * @return array< * int<0, max>, * array{ - * movie_id: ?int, - * person_id: ?int, + * tmdb_movie_id: ?int, + * tmdb_person_id: ?int, * occupation_id: value-of, * character: ?string, * order: ?int, @@ -360,11 +360,11 @@ class Movie foreach ($this->data['credits']['cast'] ?? [] as $person) { $credits[] = [ - 'movie_id' => $this->data['id'] ?? null, - 'person_id' => $person['id'] ?? null, - 'occupation_id' => Occupation::ACTOR->value, - 'character' => Str::limit($person['character'] ?? '', 200), - 'order' => $person['order'] ?? null + 'tmdb_movie_id' => $this->data['id'] ?? null, + 'tmdb_person_id' => $person['id'] ?? null, + 'occupation_id' => Occupation::ACTOR->value, + 'character' => Str::limit($person['character'] ?? '', 200), + 'order' => $person['order'] ?? null ]; } @@ -377,11 +377,11 @@ class Movie if ($job !== null) { $credits[] = [ - 'movie_id' => $this->data['id'] ?? null, - 'person_id' => $person['id'] ?? null, - 'occupation_id' => $job->value, - 'character' => null, - 'order' => null + 'tmdb_movie_id' => $this->data['id'] ?? null, + 'tmdb_person_id' => $person['id'] ?? null, + 'occupation_id' => $job->value, + 'character' => null, + 'order' => null ]; } } @@ -393,8 +393,8 @@ class Movie * @return array< * int<0, max>, * array{ - * recommendation_movie_id: ?int, - * movie_id: ?int, + * recommended_tmdb_movie_id: ?int, + * tmdb_movie_id: ?int, * title: ?string, * vote_average: ?float, * poster: ?string, @@ -404,7 +404,7 @@ class Movie */ public function getRecommendations(): array { - $movie_ids = \App\Models\Movie::query() + $movie_ids = \App\Models\TmdbMovie::query() ->select('id') ->whereIntegerInRaw('id', array_column($this->data['recommendations']['results'] ?? [], 'id')) ->pluck('id'); @@ -418,12 +418,12 @@ class Movie if ($movie_ids->contains($recommendation['id'])) { $recommendations[] = [ - 'recommendation_movie_id' => $recommendation['id'], - 'movie_id' => $this->data['id'] ?? null, - 'title' => $recommendation['title'] ?? null, - 'vote_average' => $recommendation['vote_average'] ?? null, - 'poster' => $this->tmdb->image('poster', $recommendation), - 'release_date' => $recommendation['release_date'] ?? null, + 'recommended_tmdb_movie_id' => $recommendation['id'], + 'tmdb_movie_id' => $this->data['id'] ?? null, + 'title' => $recommendation['title'] ?? null, + 'vote_average' => $recommendation['vote_average'] ?? null, + 'poster' => $this->tmdb->image('poster', $recommendation), + 'release_date' => $recommendation['release_date'] ?? null, ]; } } diff --git a/app/Services/Tmdb/Client/Season.php b/app/Services/Tmdb/Client/Season.php index 480fd0873..5da3282c2 100644 --- a/app/Services/Tmdb/Client/Season.php +++ b/app/Services/Tmdb/Client/Season.php @@ -109,7 +109,7 @@ class Season * name: ?string, * overview: ?string, * season_number: ?int, - * tv_id: int, + * tmdb_tv_id: int, * } */ public function getSeason(): array @@ -121,7 +121,7 @@ class Season 'name' => $this->data['name'] ?? null, 'overview' => $this->data['overview'] ?? null, 'season_number' => $this->data['season_number'] ?? null, - 'tv_id' => $this->tvId, + 'tmdb_tv_id' => $this->tvId, ]; } @@ -130,7 +130,7 @@ class Season * int<0, max>, * array{ * id: ?int, - * tv_id: ?int, + * tmdb_tv_id: ?int, * air_date: ?string, * name: ?string, * episode_number: ?int, @@ -140,7 +140,7 @@ class Season * season_number: ?int, * vote_average: ?float, * vote_count: ?int, - * season_id: ?int, + * tmdb_season_id: ?int, * } * > */ @@ -151,7 +151,7 @@ class Season foreach ($this->data['episodes'] ?? [] as $episode) { $episodes[] = [ 'id' => $episode['id'] ?? null, - 'tv_id' => $this->tvId ?? null, + 'tmdb_tv_id' => $this->tvId ?? null, 'air_date' => $this->tmdb->ifExists('air_date', $episode), 'name' => Str::limit($this->tmdb->ifExists('name', $episode), 200), 'episode_number' => $episode['episode_number'] ?? null, @@ -161,7 +161,7 @@ class Season 'season_number' => $episode['season_number'] ?? null, 'vote_average' => $episode['vote_average'] ?? null, 'vote_count' => $episode['vote_count'] ?? null, - 'season_id' => $this->data['id'] ?? null, + 'tmdb_season_id' => $this->data['id'] ?? null, ]; } diff --git a/app/Services/Tmdb/Client/TV.php b/app/Services/Tmdb/Client/TV.php index 6d8ac0823..9228c1bae 100644 --- a/app/Services/Tmdb/Client/TV.php +++ b/app/Services/Tmdb/Client/TV.php @@ -394,8 +394,8 @@ class TV * @return array< * int<0, max>, * array{ - * tv_id: ?int, - * person_id: ?int, + * tmdb_tv_id: ?int, + * tmdb_person_id: ?int, * occupation_id: value-of, * character: ?string, * order: ?int, @@ -409,11 +409,11 @@ class TV foreach ($this->data['aggregate_credits']['cast'] ?? [] as $person) { foreach ($person['roles'] ?? [] as $role) { $credits[] = [ - 'tv_id' => $this->data['id'], - 'person_id' => $person['id'], - 'occupation_id' => Occupation::ACTOR->value, - 'character' => Str::limit($role['character'] ?? '', 200), - 'order' => $person['order'] ?? null + 'tmdb_tv_id' => $this->data['id'], + 'tmdb_person_id' => $person['id'], + 'occupation_id' => Occupation::ACTOR->value, + 'character' => Str::limit($role['character'] ?? '', 200), + 'order' => $person['order'] ?? null ]; } } @@ -428,11 +428,11 @@ class TV if ($occupation !== null) { $credits[] = [ - 'tv_id' => $this->data['id'], - 'person_id' => $person['id'], - 'occupation_id' => $occupation->value, - 'character' => null, - 'order' => null, + 'tmdb_tv_id' => $this->data['id'], + 'tmdb_person_id' => $person['id'], + 'occupation_id' => $occupation->value, + 'character' => null, + 'order' => null, ]; } } @@ -440,11 +440,11 @@ class TV foreach ($this->data['created_by'] ?? [] as $person) { $credits[] = [ - 'tv_id' => $this->data['id'], - 'person_id' => $person['id'], - 'occupation_id' => Occupation::CREATOR->value, - 'character' => null, - 'order' => null, + 'tmdb_tv_id' => $this->data['id'], + 'tmdb_person_id' => $person['id'], + 'occupation_id' => Occupation::CREATOR->value, + 'character' => null, + 'order' => null, ]; } @@ -480,8 +480,8 @@ class TV * @return array< * int<0, max>, * array{ - * recommendation_tv_id: ?int, - * tv_id: ?int, + * recommended_tmdb_tv_id: ?int, + * tmdb_tv_id: ?int, * title: ?string, * vote_average: ?float, * poster: ?string, @@ -491,7 +491,7 @@ class TV */ public function getRecommendations(): array { - $tv_ids = \App\Models\Tv::query() + $tv_ids = \App\Models\TmdbTv::query() ->select('id') ->whereIntegerInRaw('id', array_column($this->data['recommendations']['results'] ?? [], 'id')) ->pluck('id'); @@ -505,12 +505,12 @@ class TV if ($tv_ids->contains($recommendation['id'])) { $recommendations[] = [ - 'recommendation_tv_id' => $recommendation['id'], - 'tv_id' => $this->data['id'], - 'title' => $recommendation['name'], - 'vote_average' => $recommendation['vote_average'], - 'poster' => $this->tmdb->image('poster', $recommendation), - 'first_air_date' => $recommendation['first_air_date'], + 'recommended_tmdb_tv_id' => $recommendation['id'], + 'tmdb_tv_id' => $this->data['id'], + 'title' => $recommendation['name'], + 'vote_average' => $recommendation['vote_average'], + 'poster' => $this->tmdb->image('poster', $recommendation), + 'first_air_date' => $recommendation['first_air_date'], ]; } } diff --git a/app/Traits/TorrentMeta.php b/app/Traits/TorrentMeta.php index 488907e6d..5c1e8e175 100644 --- a/app/Traits/TorrentMeta.php +++ b/app/Traits/TorrentMeta.php @@ -17,8 +17,8 @@ declare(strict_types=1); namespace App\Traits; use App\Models\IgdbGame; -use App\Models\Movie; -use App\Models\Tv; +use App\Models\TmdbMovie; +use App\Models\TmdbTv; use JsonException; use ReflectionException; @@ -41,25 +41,25 @@ trait TorrentMeta public function scopeMeta(\Illuminate\Database\Eloquent\Collection|\Illuminate\Pagination\CursorPaginator|\Illuminate\Pagination\LengthAwarePaginator|\Illuminate\Contracts\Pagination\LengthAwarePaginator $torrents): \Illuminate\Support\Collection|\Illuminate\Pagination\CursorPaginator|\Illuminate\Pagination\LengthAwarePaginator|\Illuminate\Contracts\Pagination\LengthAwarePaginator { if ($torrents instanceof \Illuminate\Contracts\Pagination\LengthAwarePaginator || $torrents instanceof \Illuminate\Contracts\Pagination\CursorPaginator) { - $movieIds = collect($torrents->items())->where('meta', '=', 'movie')->pluck('movie_id'); - $tvIds = collect($torrents->items())->where('meta', '=', 'tv')->pluck('tv_id'); + $movieIds = collect($torrents->items())->where('meta', '=', 'movie')->pluck('tmdb_movie_id'); + $tvIds = collect($torrents->items())->where('meta', '=', 'tv')->pluck('tmdb_tv_id'); $gameIds = collect($torrents->items())->where('meta', '=', 'game')->pluck('igdb'); } else { - $movieIds = $torrents->where('meta', '=', 'movie')->pluck('movie_id'); - $tvIds = $torrents->where('meta', '=', 'tv')->pluck('tv_id'); + $movieIds = $torrents->where('meta', '=', 'movie')->pluck('tmdb_movie_id'); + $tvIds = $torrents->where('meta', '=', 'tv')->pluck('tmdb_tv_id'); $gameIds = $torrents->where('meta', '=', 'game')->pluck('igdb'); } - $movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); - $tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); + $movies = TmdbMovie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id'); + $tv = TmdbTv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id'); $games = IgdbGame::with('genres')->whereIntegerInRaw('id', $gameIds)->get()->keyBy('id'); $setRelation = function ($torrent) use ($movies, $tv, $games) { $torrent->setAttribute( 'meta', match ($torrent->meta) { - 'movie' => $movies[$torrent->movie_id] ?? null, - 'tv' => $tv[$torrent->tv_id] ?? null, + 'movie' => $movies[$torrent->tmdb_movie_id] ?? null, + 'tv' => $tv[$torrent->tmdb_tv_id] ?? null, 'game' => $games[$torrent->igdb] ?? null, default => null, }, diff --git a/config/scout.php b/config/scout.php index 8f8a9bbe1..159651506 100644 --- a/config/scout.php +++ b/config/scout.php @@ -138,10 +138,10 @@ return [ App\Models\Torrent::class => [ 'searchableAttributes' => [ 'name', - 'movie.name', - 'tv.name', - 'movie.year', - 'tv.year', + 'tmdb_movie.name', + 'tmdb_tv.name', + 'tmdb_movie.year', + 'tmdb_tv.year', 'type.name', 'resolution.name', ], @@ -160,8 +160,8 @@ return [ 'user_id', 'imdb', 'tvdb', - 'movie_id', - 'tv_id', + 'tmdb_movie_id', + 'tmdb_tv_id', 'mal', 'igdb', 'season_number', @@ -191,23 +191,23 @@ return [ 'category.tv_meta', 'type.id', 'resolution.id', - 'movie.id', - 'movie.name', - 'movie.year', - 'movie.original_language', - 'movie.adult', - 'movie.genres.id', - 'movie.collection.id', - 'movie.companies.id', - 'movie.wishes.user_id', - 'tv.id', - 'tv.name', - 'tv.year', - 'tv.original_language', - 'tv.genres.id', - 'tv.networks.id', - 'tv.companies.id', - 'tv.wishes.user_id', + 'tmdb_movie.id', + 'tmdb_movie.name', + 'tmdb_movie.year', + 'tmdb_movie.original_language', + 'tmdb_movie.adult', + 'tmdb_movie.genres.id', + 'tmdb_movie.collection.id', + 'tmdb_movie.companies.id', + 'tmdb_movie.wishes.user_id', + 'tmdb_tv.id', + 'tmdb_tv.name', + 'tmdb_tv.year', + 'tmdb_tv.original_language', + 'tmdb_tv.genres.id', + 'tmdb_tv.networks.id', + 'tmdb_tv.companies.id', + 'tmdb_tv.wishes.user_id', 'playlists.id', 'bookmarks.user_id', 'freeleech_tokens.user_id', diff --git a/database/factories/RecommendationFactory.php b/database/factories/RecommendationFactory.php deleted file mode 100644 index bcb9d6033..000000000 --- a/database/factories/RecommendationFactory.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 - */ - -namespace Database\Factories; - -use App\Models\Movie; -use App\Models\Tv; -use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Recommendation; - -/** @extends Factory */ -class RecommendationFactory extends Factory -{ - /** - * The name of the factory's corresponding model. - */ - protected $model = Recommendation::class; - - /** - * Define the model's default state. - */ - public function definition(): array - { - return [ - 'title' => $this->faker->sentence(), - 'poster' => $this->faker->word(), - 'vote_average' => $this->faker->word(), - 'release_date' => $this->faker->date(), - 'first_air_date' => $this->faker->date(), - 'movie_id' => Movie::factory(), - 'recommendation_movie_id' => $this->faker->unique()->randomDigitNotNull(), - 'tv_id' => Tv::factory(), - 'recommendation_tv_id' => $this->faker->unique()->randomDigitNotNull(), - ]; - } -} diff --git a/database/factories/CollectionFactory.php b/database/factories/TmdbCollectionFactory.php similarity index 87% rename from database/factories/CollectionFactory.php rename to database/factories/TmdbCollectionFactory.php index 6d0b4b3bb..3e03ee4d1 100644 --- a/database/factories/CollectionFactory.php +++ b/database/factories/TmdbCollectionFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Collection; +use App\Models\TmdbCollection; -/** @extends Factory */ -class CollectionFactory extends Factory +/** @extends Factory */ +class TmdbCollectionFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Collection::class; + protected $model = TmdbCollection::class; /** * Define the model's default state. diff --git a/database/factories/NetworkFactory.php b/database/factories/TmdbCompanyFactory.php similarity index 87% rename from database/factories/NetworkFactory.php rename to database/factories/TmdbCompanyFactory.php index f3ebee2e2..d259a474c 100644 --- a/database/factories/NetworkFactory.php +++ b/database/factories/TmdbCompanyFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Network; +use App\Models\TmdbCompany; -/** @extends Factory */ -class NetworkFactory extends Factory +/** @extends Factory */ +class TmdbCompanyFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Network::class; + protected $model = TmdbCompany::class; /** * Define the model's default state. @@ -35,9 +35,9 @@ class NetworkFactory extends Factory return [ 'name' => $this->faker->name(), 'description' => $this->faker->text(), - 'logo' => $this->faker->word(), - 'homepage' => $this->faker->word(), 'headquarters' => $this->faker->word(), + 'homepage' => $this->faker->word(), + 'logo' => $this->faker->word(), 'origin_country' => $this->faker->word(), ]; } diff --git a/database/factories/CreditFactory.php b/database/factories/TmdbCreditFactory.php similarity index 57% rename from database/factories/CreditFactory.php rename to database/factories/TmdbCreditFactory.php index 296727991..4178676ec 100644 --- a/database/factories/CreditFactory.php +++ b/database/factories/TmdbCreditFactory.php @@ -16,20 +16,20 @@ declare(strict_types=1); namespace Database\Factories; -use App\Models\Movie; +use App\Models\TmdbMovie; use App\Models\Occupation; -use App\Models\Person; -use App\Models\Tv; +use App\Models\TmdbPerson; +use App\Models\TmdbTv; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Credit; +use App\Models\TmdbCredit; -/** @extends Factory */ -class CreditFactory extends Factory +/** @extends Factory */ +class TmdbCreditFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Credit::class; + protected $model = TmdbCredit::class; /** * Define the model's default state. @@ -37,12 +37,12 @@ class CreditFactory extends Factory public function definition(): array { return [ - 'person_id' => Person::factory(), - 'movie_id' => Movie::factory(), - 'tv_id' => Tv::factory(), - 'occupation_id' => Occupation::factory(), - 'order' => $this->faker->randomNumber(), - 'character' => $this->faker->unique()->word(), + 'tmdb_person_id' => TmdbPerson::factory(), + 'tmdb_movie_id' => TmdbMovie::factory(), + 'tmdb_tv_id' => TmdbTv::factory(), + 'occupation_id' => Occupation::factory(), + 'order' => $this->faker->randomNumber(), + 'character' => $this->faker->unique()->word(), ]; } } diff --git a/database/factories/EpisodeFactory.php b/database/factories/TmdbEpisodeFactory.php similarity index 81% rename from database/factories/EpisodeFactory.php rename to database/factories/TmdbEpisodeFactory.php index aca627277..5ea2eb7d3 100644 --- a/database/factories/EpisodeFactory.php +++ b/database/factories/TmdbEpisodeFactory.php @@ -16,17 +16,17 @@ declare(strict_types=1); namespace Database\Factories; -use App\Models\Season; +use App\Models\TmdbSeason; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Episode; +use App\Models\TmdbEpisode; -/** @extends Factory */ -class EpisodeFactory extends Factory +/** @extends Factory */ +class TmdbEpisodeFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Episode::class; + protected $model = TmdbEpisode::class; /** * Define the model's default state. @@ -38,9 +38,9 @@ class EpisodeFactory extends Factory 'overview' => $this->faker->text(), 'production_code' => $this->faker->word(), 'season_number' => $this->faker->randomNumber(), - 'season_id' => Season::factory(), + 'tmdb_season_id' => TmdbSeason::factory(), 'still' => $this->faker->word(), - 'tv_id' => $this->faker->randomDigitNotNull(), + 'tmdb_tv_id' => $this->faker->randomDigitNotNull(), 'type' => $this->faker->word(), 'vote_average' => $this->faker->word(), 'vote_count' => $this->faker->randomNumber(), diff --git a/database/factories/GenreFactory.php b/database/factories/TmdbGenreFactory.php similarity index 84% rename from database/factories/GenreFactory.php rename to database/factories/TmdbGenreFactory.php index 37664f851..eaedd4691 100644 --- a/database/factories/GenreFactory.php +++ b/database/factories/TmdbGenreFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Genre; +use App\Models\TmdbGenre; -/** @extends Factory */ -class GenreFactory extends Factory +/** @extends Factory */ +class TmdbGenreFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Genre::class; + protected $model = TmdbGenre::class; /** * Define the model's default state. diff --git a/database/factories/MovieFactory.php b/database/factories/TmdbMovieFactory.php similarity index 93% rename from database/factories/MovieFactory.php rename to database/factories/TmdbMovieFactory.php index 475f3bae3..4fcf88f87 100644 --- a/database/factories/MovieFactory.php +++ b/database/factories/TmdbMovieFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Movie; +use App\Models\TmdbMovie; -/** @extends Factory */ -class MovieFactory extends Factory +/** @extends Factory */ +class TmdbMovieFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Movie::class; + protected $model = TmdbMovie::class; /** * Define the model's default state. diff --git a/database/factories/CompanyFactory.php b/database/factories/TmdbNetworkFactory.php similarity index 87% rename from database/factories/CompanyFactory.php rename to database/factories/TmdbNetworkFactory.php index 3aa2d453f..4e4f008b0 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/TmdbNetworkFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Company; +use App\Models\TmdbNetwork; -/** @extends Factory */ -class CompanyFactory extends Factory +/** @extends Factory */ +class TmdbNetworkFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Company::class; + protected $model = TmdbNetwork::class; /** * Define the model's default state. @@ -35,9 +35,9 @@ class CompanyFactory extends Factory return [ 'name' => $this->faker->name(), 'description' => $this->faker->text(), - 'headquarters' => $this->faker->word(), - 'homepage' => $this->faker->word(), 'logo' => $this->faker->word(), + 'homepage' => $this->faker->word(), + 'headquarters' => $this->faker->word(), 'origin_country' => $this->faker->word(), ]; } diff --git a/database/factories/PersonFactory.php b/database/factories/TmdbPersonFactory.php similarity index 91% rename from database/factories/PersonFactory.php rename to database/factories/TmdbPersonFactory.php index b028f835e..6cf178f5f 100644 --- a/database/factories/PersonFactory.php +++ b/database/factories/TmdbPersonFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Person; +use App\Models\TmdbPerson; -/** @extends Factory */ -class PersonFactory extends Factory +/** @extends Factory */ +class TmdbPersonFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Person::class; + protected $model = TmdbPerson::class; /** * Define the model's default state. diff --git a/database/factories/TmdbRecommendationFactory.php b/database/factories/TmdbRecommendationFactory.php new file mode 100644 index 000000000..53c79bded --- /dev/null +++ b/database/factories/TmdbRecommendationFactory.php @@ -0,0 +1,49 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 + */ + +namespace Database\Factories; + +use App\Models\TmdbMovie; +use App\Models\TmdbTv; +use Illuminate\Database\Eloquent\Factories\Factory; +use App\Models\TmdbRecommendation; + +/** @extends Factory */ +class TmdbRecommendationFactory extends Factory +{ + /** + * The name of the factory's corresponding model. + */ + protected $model = TmdbRecommendation::class; + + /** + * Define the model's default state. + */ + public function definition(): array + { + return [ + 'title' => $this->faker->sentence(), + 'poster' => $this->faker->word(), + 'vote_average' => $this->faker->word(), + 'release_date' => $this->faker->date(), + 'first_air_date' => $this->faker->date(), + 'tmdb_movie_id' => TmdbMovie::factory(), + 'recommended_tmdb_movie_id' => $this->faker->unique()->randomDigitNotNull(), + 'tmdb_tv_id' => TmdbTv::factory(), + 'recommended_tmdb_tv_id' => $this->faker->unique()->randomDigitNotNull(), + ]; + } +} diff --git a/database/factories/SeasonFactory.php b/database/factories/TmdbSeasonFactory.php similarity index 83% rename from database/factories/SeasonFactory.php rename to database/factories/TmdbSeasonFactory.php index 209fe1fa1..ed62282ba 100644 --- a/database/factories/SeasonFactory.php +++ b/database/factories/TmdbSeasonFactory.php @@ -16,17 +16,17 @@ declare(strict_types=1); namespace Database\Factories; -use App\Models\Tv; +use App\Models\TmdbTv; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Season; +use App\Models\TmdbSeason; -/** @extends Factory */ -class SeasonFactory extends Factory +/** @extends Factory */ +class TmdbSeasonFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Season::class; + protected $model = TmdbSeason::class; /** * Define the model's default state. @@ -34,7 +34,7 @@ class SeasonFactory extends Factory public function definition(): array { return [ - 'tv_id' => Tv::factory(), + 'tmdb_tv_id' => TmdbTv::factory(), 'season_number' => $this->faker->randomNumber(), 'name' => $this->faker->name(), 'overview' => $this->faker->text(), diff --git a/database/factories/TvFactory.php b/database/factories/TmdbTvFactory.php similarity index 95% rename from database/factories/TvFactory.php rename to database/factories/TmdbTvFactory.php index cafe9c56a..1316ae89e 100644 --- a/database/factories/TvFactory.php +++ b/database/factories/TmdbTvFactory.php @@ -17,15 +17,15 @@ declare(strict_types=1); namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; -use App\Models\Tv; +use App\Models\TmdbTv; -/** @extends Factory */ -class TvFactory extends Factory +/** @extends Factory */ +class TmdbTvFactory extends Factory { /** * The name of the factory's corresponding model. */ - protected $model = Tv::class; + protected $model = TmdbTv::class; /** * Define the model's default state. diff --git a/database/factories/TorrentFactory.php b/database/factories/TorrentFactory.php index 0efa8346f..f4a97fff8 100644 --- a/database/factories/TorrentFactory.php +++ b/database/factories/TorrentFactory.php @@ -56,8 +56,8 @@ class TorrentFactory extends Factory 'user_id' => fn () => User::factory()->create()->id, 'imdb' => $this->faker->randomNumber(), 'tvdb' => $this->faker->randomNumber(), - 'movie_id' => $this->faker->randomNumber(), - 'tv_id' => $this->faker->randomNumber(), + 'tmdb_movie_id' => $this->faker->randomNumber(), + 'tmdb_tv_id' => $this->faker->randomNumber(), 'mal' => $this->faker->randomNumber(), 'igdb' => $this->faker->randomNumber(), 'type_id' => fn () => Type::factory()->create()->id, diff --git a/database/factories/TorrentRequestFactory.php b/database/factories/TorrentRequestFactory.php index 586ad7542..0e4db4be3 100644 --- a/database/factories/TorrentRequestFactory.php +++ b/database/factories/TorrentRequestFactory.php @@ -42,8 +42,8 @@ class TorrentRequestFactory extends Factory 'category_id' => Category::factory(), 'imdb' => $this->faker->randomNumber(), 'tvdb' => $this->faker->randomNumber(), - 'movie_id' => $this->faker->randomNumber(), - 'tv_id' => $this->faker->randomNumber(), + 'tmdb_movie_id' => $this->faker->randomNumber(), + 'tmdb_tv_id' => $this->faker->randomNumber(), 'mal' => $this->faker->randomNumber(), 'igdb' => $this->faker->word(), 'description' => $this->faker->text(), diff --git a/database/migrations/2025_03_17_122748_add_tmdb_prefix_to_metadata_tables.php b/database/migrations/2025_03_17_122748_add_tmdb_prefix_to_metadata_tables.php new file mode 100644 index 000000000..92f885d07 --- /dev/null +++ b/database/migrations/2025_03_17_122748_add_tmdb_prefix_to_metadata_tables.php @@ -0,0 +1,132 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 + */ + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +return new class () extends Migration { + /** + * Run the migrations. + */ + public function up(): void + { + Schema::table('movies', function (Blueprint $table): void { + $table->rename('tmdb_movies'); + }); + + Schema::table('tv', function (Blueprint $table): void { + $table->rename('tmdb_tv'); + }); + + Schema::table('torrents', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('tv_id', 'tmdb_tv_id'); + }); + + Schema::table('requests', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('tv_id', 'tmdb_tv_id'); + }); + + Schema::table('wishes', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('tv_id', 'tmdb_tv_id'); + }); + + Schema::table('collections', function (Blueprint $table): void { + $table->rename('tmdb_collections'); + }); + + Schema::table('collection_movie', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('collection_id', 'tmdb_collection_id'); + $table->rename('tmdb_collection_tmdb_movie'); + }); + + Schema::table('companies', function (Blueprint $table): void { + $table->rename('tmdb_companies'); + }); + + Schema::table('company_movie', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('company_id', 'tmdb_company_id'); + $table->rename('tmdb_company_tmdb_movie'); + }); + + Schema::table('company_tv', function (Blueprint $table): void { + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('company_id', 'tmdb_company_id'); + $table->rename('tmdb_company_tmdb_tv'); + }); + + Schema::table('genres', function (Blueprint $table): void { + $table->rename('tmdb_genres'); + }); + + Schema::table('genre_movie', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('genre_id', 'tmdb_genre_id'); + $table->rename('tmdb_genre_tmdb_movie'); + }); + + Schema::table('genre_tv', function (Blueprint $table): void { + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('genre_id', 'tmdb_genre_id'); + $table->rename('tmdb_genre_tmdb_tv'); + }); + + Schema::table('networks', function (Blueprint $table): void { + $table->rename('tmdb_networks'); + }); + + Schema::table('network_tv', function (Blueprint $table): void { + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('network_id', 'tmdb_network_id'); + $table->rename('tmdb_network_tmdb_tv'); + }); + + Schema::table('recommendations', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('recommendation_movie_id', 'recommended_tmdb_movie_id'); + $table->renameColumn('recommendation_tv_id', 'recommended_tmdb_tv_id'); + $table->rename('tmdb_recommendations'); + }); + + Schema::table('credits', function (Blueprint $table): void { + $table->renameColumn('movie_id', 'tmdb_movie_id'); + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('person_id', 'tmdb_person_id'); + $table->rename('tmdb_credits'); + }); + + Schema::table('people', function (Blueprint $table): void { + $table->rename('tmdb_people'); + }); + + Schema::table('seasons', function (Blueprint $table): void { + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->rename('tmdb_seasons'); + }); + + Schema::table('episodes', function (Blueprint $table): void { + $table->renameColumn('tv_id', 'tmdb_tv_id'); + $table->renameColumn('season_id', 'tmdb_season_id'); + $table->rename('tmdb_episodes'); + }); + } +}; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9391a423b..6999a911a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -613,10 +613,10 @@ parameters: path: app/Http/Livewire/MissingMediaSearch.php - - message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' + message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' identifier: return.type count: 2 - path: app/Http/Livewire/PersonSearch.php + path: app/Http/Livewire/TmdbPersonSearch.php - message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' @@ -649,13 +649,13 @@ parameters: path: app/Http/Livewire/TopicSearch.php - - message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' + message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' identifier: return.type count: 1 path: app/Http/Livewire/TorrentRequestSearch.php - - message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' + message: '#^Anonymous function should return Illuminate\\Database\\Eloquent\\Builder\ but returns Illuminate\\Database\\Eloquent\\Builder\\.$#' identifier: return.type count: 1 path: app/Http/Livewire/TorrentRequestSearch.php diff --git a/phpstan.neon b/phpstan.neon index 098d61985..4b0b4d8d8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,7 +17,7 @@ parameters: excludePaths: - app/Helpers/Markdown.php - app/Helpers/MarkdownExtra.php - - app/Http/Livewire/PersonCredit.php + - app/Http/Livewire/TmdbPersonCredit.php - app/Http/Livewire/TorrentSearch.php - bootstrap/cache level: 7 diff --git a/resources/views/blocks/featured.blade.php b/resources/views/blocks/featured.blade.php index c8f7a98c4..9f90d28cc 100644 --- a/resources/views/blocks/featured.blade.php +++ b/resources/views/blocks/featured.blade.php @@ -53,12 +53,12 @@ @php $meta = match (true) { - $feature->torrent->category->tv_meta => App\Models\Tv::query() + $feature->torrent->category->tv_meta => App\Models\TmdbTv::query() ->with('genres', 'networks', 'seasons') - ->find($feature->torrent->tv_id ?? 0), - $feature->torrent->category->movie_meta => App\Models\Movie::query() + ->find($feature->torrent->tmdb_tv_id ?? 0), + $feature->torrent->category->movie_meta => App\Models\TmdbMovie::query() ->with('genres', 'companies', 'collection') - ->find($feature->torrent->movie_id ?? 0), + ->find($feature->torrent->tmdb_movie_id ?? 0), $feature->torrent->category->game_meta => App\Models\Game::query() ->with('genres') ->find((int) $feature->torrent->igdb), diff --git a/resources/views/components/torrent/card.blade.php b/resources/views/components/torrent/card.blade.php index fa184d1d4..c6cec925c 100644 --- a/resources/views/components/torrent/card.blade.php +++ b/resources/views/components/torrent/card.blade.php @@ -39,7 +39,7 @@