mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
Implement pagination in schedules
This commit is contained in:
parent
65f2536e25
commit
1f1d090a24
@ -20,6 +20,11 @@ DB_ADMIN=jikan
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
###
|
||||
# Database query default values
|
||||
###
|
||||
MAX_RESULTS_PER_PAGE=25
|
||||
|
||||
###
|
||||
# Enable MyAnimeList Heartbeat
|
||||
#
|
||||
@ -110,5 +115,7 @@ PATREON=false
|
||||
PATREON_CLIENT_ID=
|
||||
PATREON_CLIENT_SECRET=
|
||||
|
||||
|
||||
###
|
||||
# OpenAPI
|
||||
###
|
||||
SWAGGER_VERSION=3.0
|
@ -142,6 +142,9 @@ class ScheduleController extends Controller
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
$page = $this->request->get('page') ?? 1;
|
||||
$limit = $this->request->get('limit') ?? (int) env('MAX_RESULTS_PER_PAGE', 25);
|
||||
|
||||
if (!is_null($day)) {
|
||||
$this->day = strtolower($day);
|
||||
}
|
||||
@ -173,8 +176,16 @@ class ScheduleController extends Controller
|
||||
->where('broadcast', 'Not scheduled once per week');
|
||||
}
|
||||
|
||||
$results = $results
|
||||
->paginate(
|
||||
$limit,
|
||||
['*'],
|
||||
null,
|
||||
$page
|
||||
);
|
||||
|
||||
$response = (new AnimeCollection(
|
||||
$results->get()
|
||||
$results
|
||||
))->response();
|
||||
|
||||
return $this->prepareResponse(
|
||||
|
Loading…
x
Reference in New Issue
Block a user