fix random err

This commit is contained in:
Constantin Plaiasu 2024-08-25 16:11:19 +03:00
parent 5a74b20425
commit 5639540f1b
2 changed files with 4 additions and 11 deletions

View file

@ -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) {

View file

@ -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