我有3个角色和一个管理面板,我想根据角色在我的面板上更改链接(和路线),但我不使用任何包...我有1个常用过滤器,1个管理过滤器,1个主持人过滤器和1个不同的用户过滤器使用不同的用户过滤器我想更改控制面板中的所有链接。 这是我的问题:
Route::group(array('before' => 'common'), function(){
Route::controller('panel','admin_PanelController');
Route::controller('phone','phneController');
Route::controller('internet','internetController');
Route::controller('message','messageController'); // siteden gelen başvurular
/* admin */
Route::group(array('before' => 'admin'), function()
{
Route::controller('useroptions','useroptionsController');
});
/* moderator */
Route::group(array('before' => 'mod'), function()
{
Route::controller('notifications','notificationsController');
});
});
/* different user */
Route::group(array('before' => 'diffuser'), function()
{
Route::controller('panel','admin_PanelController');
});
我只想将面板显示到漫射器并阻止其他路径到漫射器,但是当为不同的用户编写这些最终代码时,这些部分的上方不起作用!
请帮助我,等待帮助!
我的过滤器
Route::filter('common', function()
{
if (Auth::guest() )
{
return Redirect::guest('login');
}
});
Route::filter('admin', function()
{
if (Auth::guest() || Auth::user()->type !== "admin" )
{
return Redirect::guest('login');
}
});
Route::filter('mod', function()
{
if (Auth::guest() || Auth::user()->type !== "mod" )
{
return Redirect::guest('login');
}
});
Route::filter('diffuser', function()
{
if (Auth::guest() || Auth::user()->type !== "diffuser" )
{
return Redirect::guest('login');
}
});
答案 0 :(得分:3)
检查“漫射器”的过滤器需要应用于手机/互联网/消息,因为它需要禁止查看这些路径。试试这个:
<强> routes.php文件强>
Route::group(array('before' => 'common'), function()
{
Route::group(array('before' => 'set_links_diffuser'), function()
Route::controller('panel','admin_PanelController');
});
Route::group(array('before' => 'prohibit_diffuser'), function()
{
Route::controller('phone','phneController'); // check spelling of phne
Route::controller('internet','internetController');
Route::controller('message','messageController');
});
Route::group(array('before' => 'allow_only_admin'), function()
{
Route::controller('useroptions','useroptionsController');
});
Route::group(array('before' => 'allow_only_mod'), function()
{
Route::controller('notifications','notificationsController');
});
});
<强> filters.php 强>
Route::filter('common', function()
{
if (Auth::guest()){
return Redirect::guest('login');
}
});
// no need to repeat Auth::guest() check for these filters,
// since 'common' does that for all
Route::filter('allow_only_admin', function()
{
if (Auth::user()->type !== "admin" ){
return Redirect::guest('login');
}
});
Route::filter('allow_only_mod', function()
{
if (Auth::user()->type !== "mod" ){
return Redirect::guest('login');
}
});
Route::filter('prohibit_diffuser', function()
{
if (Auth::user()->type == "diffuser" ){
return Redirect::guest('login');
}
});
Route::filter('set_links_diffuser', function()
{
if (Auth::user()->type == "diffuser" ){
// do stuff here to change the links on the control panel
}
});