Understand what is the meaning of "to_route('route_name')" method in Laravel?
P粉494151941
P粉494151941 2023-09-15 15:54:28
0
1
574

I saw this in this tutorial:

return to_route('route_name');
Does

to_route('route_name') mean the same as redirect()->route('route_name)?

I tried to find an explanation in the Laravel documentation but didn't find any useful information.

P粉494151941
P粉494151941

reply all(1)
P粉743288436

As documentation states, to_route is a redirect, so it should be the same as 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template