dingo / api

A RESTful API package for the Laravel and Lumen frameworks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

paginator ignores last page!

ramyareye opened this issue · comments

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.x.y
Package version 1.x.y
PHP version 7.x.y

Actual Behaviour

$paginator = $this->model->with('tabs');

if (request()->has('sort') && request()->sort !== null) {
    list($sortCol, $sortDir) = explode('|', request()->sort);
    $paginator = $paginator->orderBy($sortCol, $sortDir);
} else {
    $paginator = $paginator->orderBy('id', 'desc');
}

if ($request->exists('filter')) {
    $paginator->where(function($q) use($request) {
        $value = "%{$request->filter}%";
        $q->where('name', 'like', $value);
    });
}

$paginator = $paginator->paginate(config('app.pagination_limit'));

return $this->response->paginator($paginator, new WeekTransformer());
pagination: {total: 44, per_page: 20, current_page: 1, last_page: 2, from: 1, to: 20}
current_page: 1
from: 1
last_page: 2
per_page: 20
to: 20
total: 44

Expected Behaviour

there should be 3 pages => 20 - 20 - 4 but it's two :-(

Possible to help me manage this?

Regards

commented

Hello @ramyareye

Version 1 of dingo is quite old and unsupported, and you did not specify your laravel version. You will need to at least update Dingo to the latest version, and then make sure laravel is at least 5.5+ as we do not support any earlier version.

Thanks