I have one solution in mind.
Just make One extra fake controller
and make index action
of that controller.
In this index
action we can have our own permission check
and based on that we can redirect user to our predefined location.
Now for main menu
just point URL to => myplugin/fakecontroller/index
this controller has no permission
means its public
so every one can use it.
Now in index action
check permission of current user
and based on that you can select redirect url
.
// in fakecontroller's index action
$redirectUrl = 'default-url';
if($this->user->hasAccess('bla-bla')) {
$redirectUrl = 'some-other-url';
}
return \Redirect::to($redirectUrl);
To make it more dynamic with multiple plugins
To make it more dynamic you can just pass id
of plugin to index
action. make sure plugin url will be same for all other plugins. we just change id
Any how you have to use if statements because you want custom behaviour and i don't think we can add those info in to backend and if we try to implement that it will take too long. So, for now I have other solution
which can make it little bit easy with multiple plugins
.
for ex.
- for plugin-A main menu url could be
myplugin/fakecontroller/index/plugin-A
- for plugin-B main menu url could be
myplugin/fakecontroller/index/plugin-B
// fakecontroller
$pluginWiseRedirect = [
'pluginA' => [
'permission-name' => 'redirect-url-A',
'bla-bla' => 'new-url-A'
],
'pluginB' => [
'permission-name' => 'redirect-url-B',
'bla-bla' => 'new-url-B'
],
];
// in fakecontroller's index action
public function index($pluginId = 'pluginA') {
$redirectUrl = 'default-url';
$permissionName = 'permission-name';
if($this->user->hasAccess($permissionName)) {
// please make check here for key exist
$redirectUrl = $this->pluginWiseRedirect[$pluginId][$permissionName];
}
$permissionName = 'bla-bla';
if($this->user->hasAccess($permissionName)) {
// please make check here for key exist
$redirectUrl = $this->pluginWiseRedirect[$pluginId][$permissionName];
}
return \Redirect::to($redirectUrl);
}
if any doubts please comment.