草庐IT

CustomerController

全部标签

php - laravel 路由过滤器来检查用户角色

我正在laravel4中构建一个restfulapi,其中有具有不同类型权限的用户。我想根据用户角色(保存在db的用户表中)限制对不同路由的访问我该怎么做?这是我到目前为止所拥有的(到目前为止还没有用)。过滤器.php//allowsbackendapiaccessdependingontheuser'sroleoncetheyareloggedinRoute::filter('role',function(){returnAuth::user()->role;});路由.phpRoute::group(array('before'=>'role'),function($role){i