From 5639540f1beb9c5201f1337d634294f2acda9772 Mon Sep 17 00:00:00 2001 From: Constantin Plaiasu Date: Sun, 25 Aug 2024 16:11:19 +0300 Subject: [PATCH] fix random err --- app/Services/TmdbClient.php | 6 +++--- app/Supports/Traits/CleanItems.php | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/Services/TmdbClient.php b/app/Services/TmdbClient.php index f43d099..0f8beb2 100644 --- a/app/Services/TmdbClient.php +++ b/app/Services/TmdbClient.php @@ -128,7 +128,7 @@ public function getMovie(int $id) $call = fn() => $this->formatTmdbMovie($this->client->getMoviesApi()->getMovie($id, ['append_to_response'=>'credits,videos,similar,keywords'])); if ($this->use_cache) - return Cache::remember('movie'.$id, $this->ttl, $call); + return Cache::remember('movie:'.$id, $this->ttl, $call); return $call(); } catch (\Throwable $th) { @@ -140,9 +140,9 @@ public function getShow(int $id) { try { - $call = fn() => $this->client->getTvApi()->getTvshow($id, ['append_to_response'=>'credits,videos,similar,recommendations,keywords']); + $call = fn() => $this->formatTmdbShow($this->client->getTvApi()->getTvshow($id, ['append_to_response'=>'credits,videos,similar,recommendations,keywords'])); if ($this->use_cache) - return Cache::remember('show'.$id, $this->ttl, $call); + return Cache::remember('show:'.$id, $this->ttl, $call); return $call(); } catch (\Throwable $th) { diff --git a/app/Supports/Traits/CleanItems.php b/app/Supports/Traits/CleanItems.php index acecb4e..58f9b66 100644 --- a/app/Supports/Traits/CleanItems.php +++ b/app/Supports/Traits/CleanItems.php @@ -181,26 +181,19 @@ public static function encodeForInertia($data):string public function getHomeHeroSliderData($movies, TmdbClient $tmdb) { - return Cache::remember('home_hero_slider_nyxy', 3600 * 6, function()use($movies, $tmdb){ + return Cache::remember('home_hero_slider', 3600 * 6, function()use($movies, $tmdb){ $movies = (array)$movies; - // dd($movies['data']); $movies = collect($movies['data'])->map(fn($item) => self::setItemTypeMovie((array)$item))->map(function($movie) use($tmdb){ $movie = (array)$movie; return $tmdb->getMovie($movie['id']); - // dd($this->formatTmdbMovie($movie)); - // return $this->formatTmdbMovie($movie); }) ->map(function($item){ $item['overview'] = Str::limit($item['overview'], 250); return $item; }); - // dd($movies); return $movies->all(); }); - - // $shows = collect($shows['data'])->map(fn($item) => self::setItemTypeShow($item)); - // dd($movies, $shows); } public function formatApiResponse(Object $data, $with_pagination = true, $route = [], $limit = false): array