scottjo's avatar

Remembering Pagination Page

Hi folks

Apologies if this has been asked before but I feel I must be missing something straightforward in respect to pagination. I have an administration page with a paginated set of data which works a treat.

Each row has a link that goes off to an edit page - nothing very exciting here. The user returns back to the index page - either by cancel or saving changes etc. and I use the redirect->back() method to take me back to the index page - It seems to lose the 'current page' of the pagination and returns me to the start of the index list ie page 1.

What is the recommended routine for this? do I have to remember the page number for this particular page and set it in my controller when I want to show the index? or is there an elegant Laravel way?

Thanks for any advice

Jon

0 likes
2 replies
SaeedPrez's avatar

Hi @scottjo

You will have to pass it along in each request or save it somehow.. I guess the easiest and cleanest way would be to save the page number in session, then in your controller..

  1. Check if URI parameter ?page=x exists
  2. If not, then check if page number exists in session
scottjo's avatar

Thanks for your advice. I will store it in the session and use that when not on the URI.

Thanks again

Please or to participate in this conversation.