Ejemplo n.º 1
0
 public function registerMarkupTags()
 {
     return ['functions' => ['can' => function ($can) {
         return Group::can($can);
     }, 'hasRole' => function ($role, $user = null) {
         return Group::hasRole($role, $user);
     }]];
 }
Ejemplo n.º 2
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $roleId) {
             if (!($role = Group::find($roleId))) {
                 continue;
             }
             $role->delete();
         }
         Flash::success('The role has been deleted successfully.');
     }
     return $this->listRefresh();
 }
Ejemplo n.º 3
0
 public static function can($permissions)
 {
     $account = new Account();
     $permissions = !is_array($permissions) ? [$permissions] : $permissions;
     if (Auth::check()) {
         $roles = json_decode(User::find($account->user()->id)->groups);
         foreach ($roles as $role) {
             foreach (Group::find($role->id)->perms as $perm) {
                 if (in_array($perm->name, $permissions)) {
                     return true;
                 }
             }
         }
     }
 }