I am currently trying to save the current page from Pagination throughout my project pages.
Why?
The reason is that I would like to go to a detail page of let's say data xy in an overview list, maybe even say I would like to edit it, but then decide to go back to the overview list of all data.
So this would mean:
overview page --> select data xy (detailpage) --> edit data xy (edit page)
overview page <--------- go back from edit data xy (edit page)
My Controller code:
public function index(Request $request, $current_page = 1)
{
$data = self::paginate(11);
return $data;
if($current_page) $data->current_page = $current_page;
return view('dashboard.data.index')->with(array('data' => $data));
}
public function details(Request $request, $id, $current_page = 1)
{
$datadetail = Data::where('id', $id)->firstOrFail();
return view('dashboard.data.detail')->with(array('detail' => $datadetail, 'current_page' => $current_page));
}
This is not working. When I click on the following button on detail view:
<a class="btn btn-primary btn-back" href="{{ URL::action("DataController@index", array('current_page' => $current_page)) }}"><span class="glyphicon glyphicon-chevron-left"></span></a>
this leads back to the overview page, BUT always to page 1, even if it was handed over originally from index to detail view as 3 or 4...
My question:
How can I tell the Paginator to load the page number I am handing over?