If everything is properly ran through the controller the pagination will be correct. But after importing 20 records of course the pagination order will change and you may have to start fresh with page one again.
Mar 27, 2018
5
Level 3
Update records/pagination after reloading the view.
Scenario:
- I have a view, dealers.blade, that shows in a the contents of a single table.
- the view has a pagination control,
{{$dealers->links()}}, and the controller sends pagianate(10) to the view. The - The records of the dealers table are added by importing an excel file.
- the file upload field and the importer button are in the same blade.
Question:
- say we have 20 dealers. When I access the view, I can see pages 1 and 2 on the pagination control. This is fine.
- now, using the very same page, I select a file, upload it and add to the dealers table. Dealer table now has 40 records/
- the pagination control should show 4 pages, but it is still showing 2 pages (because the previous count was 20 records). In other words, the view is still showing the same old 20 records.
- Now I import 10 more records and the view now shows 4 pages (from the previous import) instead of five.
- in any case, if I hit the "go to the last record" button, the pagination control is updated by itself.
After importing the data, I call the view using:
return view('app.dealers',[<<variables>>]);
Basically I need to show the new records when I call the view again. If the new records are show, the pagination control will be updated by itself, I guess.
TIA!
Please or to participate in this conversation.