I want to create a redirect method that could be called from other methods. Unfortunately, I can't do it as I want (see source below).
I propose a solution, but I want to redirect just calling the method, not doing more stuff.
My solution:
class FooController extends Controller
{
public function foo(Request $request)
{
if ($result = $this->__check($request)) {
return $result;
}
return view('foo');
}
private function __ckeck(Request $request)
{
if (doSomething) {
return redirect('/');
}
return false;
}
}
What I want:
class FooController extends Controller
{
public function foo(Request $request)
{
$this->__check($request);
return view('foo');
}
private function __ckeck(Request $request)
{
if (doSomething) {
// redirect source <--- what I want
}
return false;
}
}