Reputation: 2603
I have a catchall route configured in laravel like below:
// catch all
Route::get('{catchall}', [
'uses' => 'MyGenericController@index'
])->where('catchall', '(.*)');
Route::put('{catchall}', [
'uses' => 'MyGenericController@update'
])->where('catchall', '(.*)');
And in the MyGenericController I am redirecting back in the update() action if something went wrong. And then I am checking for the values in request object in the index action/method as below:
class MyGenericController extends MyBaseController {
public function index($paramNameAtTheEndOfUrl) {
// Check if any data exist in Request because of failure from update
\Log::info( " data = " . print_r(request()->all(), true) );
} // index
public function update((Request $request) {
try {
...
// Do somethings
} catch (\Exception $e) {
return back()->withInput($request->all())->withErrors([$e->getMessage()]);
}
} // Update
}
Now what I am observing is that the index method is not receiving the request object data when I get exception in update and I redirect back.
So as per my understanding, if I am doing a back() call in update() method/action using withInput(request()->all()) and withError(...), I should be expecting the old values in my index() action.
But I see empty request ( no input data passed back ) in the index() method.
Why is this happening?
Upvotes: 0
Views: 87
Reputation: 9962
This is how you get old input (->old()
instead of ->all()
):
\Log::info( " data = " . print_r(request()->old(), true) );
Upvotes: 0