I saw this in this tutorial:
return to_route('route_name');
to_route('route_name') mean the same as redirect()->route('route_name)?
to_route('route_name')
redirect()->route('route_name)
I tried to find an explanation in the Laravel documentation but didn't find any useful information.
As documentation states, to_route is a redirect, so it should be the same as redirect()->route('name').
to_route
redirect()->route('name')
You can also view the official source code , I will copy paste the code:
function to_route($route, $parameters = [], $status = 302, $headers = []) { return redirect()->route($route, $parameters, $status, $headers); }
So, you can see, it's actually a redirect just like you posted.
Always check the official source code, you will (most of the time) understand and see what some of the code does.
As documentation states,
to_route
is a redirect, so it should be the same asredirect()->route('name')
.You can also view the official source code , I will copy paste the code:
So, you can see, it's actually a redirect just like you posted.
Always check the official source code, you will (most of the time) understand and see what some of the code does.