framework: Paginate method doesn't work if key contains array notation
- Laravel Version: 5.4
- PHP Version: 7.1
Description:
If pagination key is of array notation (ie. page[published]
, page[unpublished]
) when on ?page[published]=5
the value is not taken into consideration (it still displays first page)
Steps To Reproduce:
- Paginate given dataset using
paginate(10, ['*'], 'page[published]')
- Display given dataset on view using
links()
- Go to one of the urls generated by the pagination
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (13 by maintainers)
You pass
page.published
topaginate
method.PageResolver
will use it ininput
method onrequest
to retrieve current page.input
method is working with dot notation, that is why we passpage.published
here. So, we createdPaginator
withpage.published
pageName
. If we will uselinks
method on such paginator, it creates smth likepage.published=2
which is not what we want. So, we change its name topage[published]
for correct link generation. Does it make sense now? 😃You can override the page resolver using
AbstractPaginator::currentPageResolver()
, then add in support yourself. That would at least means you can support it in your own application even if it is not to be supported in the framework.