I have two controllers
App\Http\Controllers\Controller\StartController
App\Http\Controllers\Controller\Legacy\StartLegacyController
When I receive request at my first controller, I check if request contains version=legacy
if yes then I want to redirect that request to StartLegacyController@index
Action
Else I'll process the request in StartController
itself. Here's my code from StartController
public function index(Request $request)
{
$version = $request->input('version', 'legacy');
if ($version == 'legacy') {
return Redirect::action('App\Http\Controllers\Legacy\StartLegacyController@index');
}
dd('OKK',$request->all());
}
I am getting
(1/1) RuntimeException
A facade root has not been set.
I Tried to remove Namespace, even put controller in the same namespace but it isn't working, will really appreciate any kind of help.
EDIT
Since Redirect::action()
not working in this case I've come up with a temporary solution to my problem with as @Ali Mrj suggested
$router->get('/start', function (\Illuminate\Http\Request $request) use ($router) {
$version = $request->input('version', 'legacy');
if($version == 'legacy'){
$controller = $router->app->make('App\Http\Controllers\Legacy\StartLegacyController');
return $controller->index();
} else{
$controller = $router->app->make('App\Http\Controllers\StartPageController');
return $controller->index($request);
}
});
Will appreciate other solutions for the issue...
I think the following code will do it for you:
return redirect()->action('StartLegacyController@index');