is there any way to create previous and next recording of each episode on laravel?
this is what i have
My controller:
public function getEpisode(Request $request, $movie, $slug, $id)
{
$movie = Movie::fromCache()->find($movie)->load('episodes');
if (is_null($movie)) abort(404);
/** @var Episode */
$episode = $movie->episodes->when($id, function ($collection, $id) {
return $collection->where('id', $id);
})->firstWhere('slug', $slug);
if (is_null($episode)) abort(404);
$episode->generateSeoTags();
$movie->increment('view_total', 1);
$movie->increment('view_day', 1);
$movie->increment('view_week', 1);
$movie->increment('view_month', 1);
$movie_related_cache_key = 'movie_related.' . $movie->id;
$movie_related = Cache::get($movie_related_cache_key);
if(is_null($movie_related)) {
$movie_related = $movie->categories[0]->movies()->inRandomOrder()->limit(12)->get();
Cache::put($movie_related_cache_key, $movie_related, setting('site_cache_ttl', 5 * 60));
}
return view('themes::themebptv.episode', [
'currentMovie' => $movie,
'movie_related' => $movie_related,
'episode' => $episode,
'title' => $episode->getTitle()
]);
}
I have tried creating the previous and next buttons but it doesn’t work at all. I hope someone can help me