Looking at a lot of implementations I've seen that people use a certain frequency return redirect()->back()
... My question is:
What is the difference between return redirect()->back()
... and return back()
...
Looking at a lot of implementations I've seen that people use a certain frequency return redirect()->back()
... My question is:
What is the difference between return redirect()->back()
... and return back()
...
These are two ways to do the same thing, ie redirect to the previous location and are functions that return the instance of class Redirector
and its main goal is to facilitate development
Structures:
back()
function back($status = 302, $headers = [], $fallback = false)
{
return app('redirect')->back($status, $headers, $fallback);
}
redirect()
function redirect($to = null, $status = 302, $headers = [], $secure = null)
{
if (is_null($to)) {
return app('redirect');
}
return app('redirect')->to($to, $status, $headers, $secure);
}
On structures, the redirect
can call the other methods, while back()
would already be the method call, both forms are correct, but, back()
in that case fits better.