Flashing Input To The Session
The flash
method on the Illuminate\Http\Request
class will flash the current input to the session so that it is available during the user's next request to the application:
$request->flash();
flashOnly
and flashExcept
methods to flash a subset of the request data to the session. These methods are useful for keeping sensitive information such as passwords out of the session:
$request->flashOnly(['username', 'email']);
$request->flashExcept('password');
Flashing Input Then Redirecting
Since you often will want to flash input to the session and then redirect to the previous page, you may easily chain input flashing onto a redirect using the withInput
method:
return redirect('form')->withInput();
return redirect('form')->withInput(
$request->except('password')
);
Retrieving Old Input
To retrieve flashed input from the previous request, use the old
method on the Request
instance. The old
method will pull the previously flashed input data from the session:
$username = $request->old('username');
old
helper. If you are displaying old input within a Blade template, it is more convenient to use the old
helper. If no old input exists for the given field, null
will be returned:
<input type="text" name="username" value="{{ old('username') }}">
To know more about Retrieve Input Data In Laravel visit our Bajarangisoft site.