Difference Between redirect('hoge') and redirect()->to('hoge') in Laravel

A minor detail, but I was curious, so I decided to look into it.

I've been using this method without much thought, but...

This one works just as well, so I decided to investigate the implementation of the redirect helper.

Implementation of the redirect Helper

It seems that if the argument is null, it will return an instance. This is also mentioned in the documentation lol.

The API of the instance being called can be found here.

The implementation of the to method is as follows:

Conclusion

redirect('hoge') and redirect()->to('hoge') are the same.

If you just want a simple redirect, use redirect('hoge'). If you need to include flash data or redirect to a controller method, use redirect() to return an instance.

Personal Note

Since I started using Laravel, I've been writing code unconsciously. This made me realize that I should take a moment to review the implementation of the code I use regularly. φ(..)