just type this
echo '<script type="text/javascript">'
, 'history.go(-2);'
, '</script>';
I would not rely on JavaScript code as JS may be disabled in a browser. Instead, at step 2 I would put:
Session::flash('url',Request::server('HTTP_REFERER'));
and then at step 4 I would redirect to the URL which is saved in the session variable:
return Redirect::to(Session::get('url'));
sayasuhendra said:
just type this
echo '<script type="text/javascript">' , 'history.go(-2);' , '</script>';
Your solution will redirect to second last page but can not load new customer.
Alkimisti said:
I would not rely on JavaScript code as JS may be disabled in a browser. Instead, at step 2 I would put:
Session::flash('url',Request::server('HTTP_REFERER'));
and then at step 4 I would redirect to the URL which is saved in the session variable:
return Redirect::to(Session::get('url'));
This solution is mean When you in step one, you flash session url now and you can get session url after submit new customer
Flash url in YourController@index
Session::flash('backUrl', Request::fullUrl());
Keep the sub session key in YourController@create and YourController@store
if (Session::has('backUrl')) {
Session::keep('backUrl');
}
Consume the session value in YourController@store or any subsequent views
// YourController@store
return ($url = Session::get('backUrl'))
? Redirect::to($url)
: Redirect::route('any.named.route');
// or any views
@if ($url = Session::get('backUrl'))
<a href="$url">Back to List</a>
@endif
Step 1 uses get tokens. Simply save the full URL in a session variable and use it to redirect in step 4. No need to over think it.
appkr said:
Flash url in YourController@index
Session::flash('backUrl', Request::fullUrl());
Keep the sub session key in YourController@create and YourController@store
if (Session::has('backUrl')) { Session::keep('backUrl'); }
Consume the session value in YourController@store or any subsequent views
// YourController@store return ($url = Session::get('backUrl')) ? Redirect::to($url) : Redirect::route('any.named.route'); // or any views @if ($url = Session::get('backUrl')) <a href="$url">Back to List</a> @endif
Your answer solve my problem. Thanks a bunch
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community