Skip to content

Commit

Permalink
Added pagination variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ipkpjersi committed Jun 24, 2024
1 parent 60f9245 commit 73e822f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Http/Controllers/AnimeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ public function userAnimeList(Request $request, $username)
if ($request->has('showallanime') && $request->input('showallanime') === '1' && Auth::user() !== null && strtolower(Auth::user()->username) === strtolower($user->username)) {
$showAllAnime = true;
}
$pagination = $user->anime_list_pagination_size ?? 15;
if ($request->has('size') || $request->has('pageSize') || $request->has('pagesize')) {
$pagination = $request->get('size') ?? $request->get('pageSize') ?? $request->get('pagesize');
$pagination = max(1, min((int) $pagination, 1000)); //Clamp between 1 and 1000
}
$show_anime_list_number = Auth::user() != null && Auth::user()->show_anime_list_number == 1;
$watchStatuses = DB::table('watch_status')->get();
$watchStatusMap = $watchStatuses->pluck('status', 'id')->toArray();
Expand Down Expand Up @@ -418,7 +423,7 @@ public function userAnimeList(Request $request, $username)
$query = $query->where('anime_user.watch_status_id', $watchStatusId);
}
}
$userAnime = $query->paginate($user->anime_list_pagination_size ?? 15)->withQueryString();
$userAnime = $query->paginate($pagination ?? 15)->withQueryString();

return view('userAnimeList', ['userAnime' => $userAnime, 'username' => $username, 'show_anime_list_number' => $show_anime_list_number, 'watchStatuses' => $watchStatuses, 'watchStatusMap' => $watchStatusMap]);
}
Expand Down

0 comments on commit 73e822f

Please sign in to comment.