From 608e659ee0454183ded2f98caa004f48fb7f520f Mon Sep 17 00:00:00 2001 From: Roardom Date: Thu, 4 Jul 2024 04:46:15 +0000 Subject: [PATCH] update: use logical `OR` when searching tmdb/imdb/tvdb/malid --- app/Http/Controllers/API/TorrentController.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/API/TorrentController.php b/app/Http/Controllers/API/TorrentController.php index 7521207328..d64efe08af 100644 --- a/app/Http/Controllers/API/TorrentController.php +++ b/app/Http/Controllers/API/TorrentController.php @@ -533,10 +533,17 @@ public function filter(Request $request): TorrentsResource|\Illuminate\Http\Json ->when($request->filled('types'), fn ($query) => $query->ofType($request->types)) ->when($request->filled('resolutions'), fn ($query) => $query->ofResolution($request->resolutions)) ->when($request->filled('genres'), fn ($query) => $query->ofGenre($request->genres)) - ->when($request->filled('tmdbId'), fn ($query) => $query->ofTmdb((int) $request->tmdbId)) - ->when($request->filled('imdbId'), fn ($query) => $query->ofImdb((int) $request->imdbId)) - ->when($request->filled('tvdbId'), fn ($query) => $query->ofTvdb((int) $request->tvdbId)) - ->when($request->filled('malId'), fn ($query) => $query->ofMal((int) $request->malId)) + ->when( + $request->filled('tmdbId') || $request->filled('imdbId') || $request->filled('tvdbId') || $request->filled('malId'), + fn ($query) => $query->where( + fn ($query) => $query + ->whereRaw('1=1') + ->when($request->filled('tmdbId'), fn ($query) => $query->orWhere('tmdb', '=', $request->integer('tmdbId'))) + ->when($request->filled('imdbId'), fn ($query) => $query->orWhere('imdb', '=', $request->integer('imdbId'))) + ->when($request->filled('tvdbId'), fn ($query) => $query->orWhere('tvdb', '=', $request->integer('tvdbId'))) + ->when($request->filled('malId'), fn ($query) => $query->orWhere('mal', '=', $request->integer('malId'))) + ) + ) ->when($request->filled('playlistId'), fn ($query) => $query->ofPlaylist((int) $request->playlistId)) ->when($request->filled('collectionId'), fn ($query) => $query->ofCollection((int) $request->collectionId)) ->when($request->filled('primaryLanguages'), fn ($query) => $query->ofPrimaryLanguage($request->primaryLanguages))