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:

  1. Paginate given dataset using paginate(10, ['*'], 'page[published]')
  2. Display given dataset on view using links()
  3. 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)

Most upvoted comments

You pass page.published to paginate method. PageResolver will use it in input method on request to retrieve current page. input method is working with dot notation, that is why we pass page.published here. So, we created Paginator with page.published pageName. If we will use links method on such paginator, it creates smth like page.published=2 which is not what we want. So, we change its name to page[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.