Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0

just type this

echo '<script type="text/javascript">'
			   , 'history.go(-2);'
			   , '</script>';
Last updated 2 years ago.
0

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'));  
Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

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
Last updated 9 years ago.
0

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.

0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Sharping sharping Joined 28 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.