Reputation: 304
In my program i called a controller function using redirect action method which is commonly applied for 2 prefix routes(admin,manager) when i am on admin route i tried to call the controller function which triggers the manager route controller function here is the controller call
return redirect()->action('UserController@index');
prefix routes definied
Route::group(array('prefix' => 'admin'), function(){
Route::get('/user', 'UserController@index');
});
Route::group(array('prefix' => 'manager'), function(){
Route::get('/user', 'UserController@index');
});
when i am on admin prefix localhost/admin/user route. i triggered controller call return redirect()->action('UserController@index'); which triggers the manager prefix controller. the route will changed to localhost/manager/user why this is happening please help me on this and i am using LARAVEL 5.2
Thanks in advance
Upvotes: 1
Views: 610
Reputation: 1160
You can use the Named Routed to avoid the conficts.
In your route give name to every route.
Route::group(array('prefix' => 'admin'), function(){
Route::get('/user', array('as' => 'admin.user', 'uses' => 'UserController@index');
});
Route::group(array('prefix' => 'manager'), function(){
Route::get('/user', array('as' => 'manager.user', 'uses' => 'UserController@index');
});
Now in your route
you can routed by it's name,
return redirect()->route('admin.user');
or
return redirect()->route('manager.user');
It might help you.
Upvotes: 2