I have set up pagination and it's working correctly. How do I access the pagination object in my edit function.
E.g: If i update the row on currencies?page=2 it's redirecting me on currencies. How do i set up and redirect to currencies?page=2 on update function if i'm on currencies?page=2.
Controller - index function
public function index()
{
$currencies = Currency::paginate(5);
return view('admin.currencies.index')
->withCurrencies($currencies);
}
Controller - Edit function
public function edit($id)
{
$currency = Currency::findOrFail($id);
return view('admin.currencies.edit')
->withCurrency($currency);
}
Controller - Update function
public function update(Request $request, $id)
{
$currency = Currency::findOrFail($id);
$currency->name = $request->name;
$currency->rate = $request->rate;
$currency->save();
return redirect()->route('currencies.index')->with('message', 'Done');
}
Views
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire