I have link :
example.com/register#register
If validation fails laravel redirects to :
example.com/register
with validation errors bit without hash url part. How I can redirect to full url with # ?
I know I can use:
Redirect::to(route('register') . '#credits')
But I want complete solution so and my :
return back();
will redirect with #.
Maybe I need to override some code ?
You could create the URL first, using the route name.
$url = URL::route('route_name', ['#hash_tag']);
Redirect::to($url);
Or...
return Redirect::to(URL::previous() . "#hash_tag");
But if you want to get the proper URL where hash is the fragment part and not a parameter you should use:
redirect(route('route_name', ['some_param_for_route']). '#hash')
instead of:
redirect()->route('route_name', [ 'some_param_for_route', '#hash' ])
so to get:
http://example.com/some_param_for_route#hash
and not:
http://example.com/some_param_for_route?#hash
this way you can also chain it further like for instance:
redirect(route('route_name', ['some_param']). '#hash')->with('status', 'Profile updated!');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With