-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laravel 5 Pagination Support #3
Comments
Thanks for reporting. I don't have a running ElasticSearch setup, so you'd help if you can test. L5 has changed a bit how the Paginator works and removed the facade. |
I performed a search with Anyways this just shows results for the first page and pagination never gets displayed. Dumping the
And without the
So even though it doesn't show any errors, The pagination links are not displayed. |
And i confirm the pagination works when i directly change the And except the first page |
The new paginator is either buggy or I don't understand it fully. Having an incorrect url is understandable, but not having the links display on the first page makes no sense. I'll investigate. |
I managed to fix both wrong URLs and not displaying at the first page (at least for my use case) by changing /**
* Paginates the Elasticsearch results.
*
* @param int $perPage
* @return mixed
*/
public function paginate($perPage = 15)
{
$page = Paginator::resolveCurrentPage() ?: 1;
$path = '/' . \Request::path();
$sliced = array_slice($this->items, ($page - 1) * $perPage, $perPage);
return new Paginator($sliced, $perPage, $page, compact('path'));
} |
Oh, and btw this is Laravel 5' simple pagination, so The L5 equivalent to use Illuminate\Pagination\LengthAwarePaginator;
...
/**
* Paginates the Elasticsearch results.
*
* @param int $perPage
* @return mixed
*/
public function paginate($perPage = 15)
{
$page = Paginator::resolveCurrentPage() ?: 1;
$path = '/' . \Request::path();
$sliced = array_slice($this->items, ($page - 1) * $perPage, $perPage);
$total = count($this->items);
return new LengthAwarePaginator($sliced, $total, $perPage, $page, compact('path'));
} |
@rscafi can you create a pull request on the l5 branch using your modification? Preferably using the new LengthAwarePaginator. |
@fadion sure I can. I'm just testing it a little longer. |
It would be great! I can create a "dev" branch and give you commit access. What do you think? |
@fadion I have modified the code according to AlexanderWright's code it worked fine. Kindly accept his merge request. |
Hi,
Can you add support for Laravel 5 Pagination? The current implementation doesn't work and it throws an error "Class 'Illuminate\Support\Facades\Paginator' not found - since it doesn't exist", And the errors keeps on coming for every fix made.
Hopefully you will provide a fix soon.
Thanks.
The text was updated successfully, but these errors were encountered: