0

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 finding an explanation in the Laravel docs, but couldn't find it helpful.

1 Answer 1

2

As the documentation states, to_route does redirect, so it should be the same as redirect()->route('name').

You can also check 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 is literally a redirect as you posted.

ALWAYS check the official source code, and you will (most of the time) understand and see what some code does

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.