当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::getRoleMaskByName方法代码示例

本文整理汇总了PHP中app\Role::getRoleMaskByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getRoleMaskByName方法的具体用法?PHP Role::getRoleMaskByName怎么用?PHP Role::getRoleMaskByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Role的用法示例。


在下文中一共展示了Role::getRoleMaskByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPermissions

 /**
  * Return the user's entire permission object,
  * build it if nessecary.
  *
  * @return array
  */
 protected function getPermissions()
 {
     if (!isset($this->permissions)) {
         $rememberTags = ["user.{$this->user_id}", "permissions"];
         $rememberTimer = 3600;
         $rememberKey = "user.{$this->user_id}.permissions";
         $rememberClosure = function () {
             $permissions = [];
             // Fetch our permission mask.
             if ($this->isAnonymous()) {
                 $permissions["anonymous"] = Role::getRoleMaskByName("anonymous");
                 if (!$this->isAccountable()) {
                     $permissions["unaccountable"] = Role::getRoleMaskByName("unaccountable");
                 }
             } else {
                 $userRoles = [];
                 foreach ($this->roles as $role) {
                     $userRoles[] = $role->role_id;
                 }
                 if (!count($userRoles)) {
                     $permissions = Role::getRoleMaskByName("anonymous");
                 } else {
                     $permissions = Role::getRoleMaskByID($userRoles);
                 }
             }
             return $permissions;
         };
         switch (env('CACHE_DRIVER')) {
             case "file":
             case "database":
                 $this->permissions = Cache::remember($rememberKey, $rememberTimer, $rememberClosure);
                 break;
             default:
                 $this->permissions = Cache::tags($rememberTags)->remember($rememberKey, $rememberTimer, $rememberClosure);
                 break;
         }
     }
     return $this->permissions;
 }
开发者ID:Ryangr0,项目名称:infinity-next,代码行数:45,代码来源:PermissionUser.php

示例2: getPermissions

 /**
  * Return the user's entire permission object,
  * build it if nessecary.
  *
  * @return array
  */
 protected function getPermissions()
 {
     if (!isset($this->permissions)) {
         $this->permissions = Cache::remember("user.{$this->user_id}.permissions", 3600, function () {
             $permissions = [];
             // Fetch our permission mask.
             if ($this->isAnonymous()) {
                 $permissions["anonymous"] = Role::getRoleMaskByName("anonymous");
                 if (!$this->isAccountable()) {
                     $permissions["unaccountable"] = Role::getRoleMaskByName("unaccountable");
                 }
             } else {
                 $userRoles = [];
                 foreach ($this->roles as $role) {
                     $userRoles[] = $role->role_id;
                 }
                 if (!count($userRoles)) {
                     $permissions = Role::getRoleMaskByName("anonymous");
                 } else {
                     $permissions = Role::getRoleMaskByID($userRoles);
                 }
             }
             return $permissions;
         });
     }
     return $this->permissions;
 }
开发者ID:ee-ee,项目名称:infinity-next,代码行数:33,代码来源:PermissionUser.php


注:本文中的app\Role::getRoleMaskByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。