1

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.