Get permissions and roles of an route

@param  string
@return RoutePermission
334129
public static function getRoutePermissionsRoles($route)
    {
        $routePermission = parent::where('route', $route)->first();
        if (empty($routePermission)) {
            return null;
        }
        $routePermission->permissions = json_decode($routePermission->permissions);
        $routePermission->roles = json_decode($routePermission->roles);
        return $routePermission;
    }
151641
public function getRolesWithPermissions(): Collection
    {
        return $this->roleRepository->makeQuery()
            ->with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()
            ->map(function (HCAclRole $role) {
                return [
                    'id' => $role->id,
                    'role' => $role->name,
                    'slug' => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });
    }
1282570
public function getPermissions()
    {
        $permissions = [];
        foreach ($this->roles as $role) {
            $permissions = array_merge($permissions, $role->getPermissions());
        }
        return array_unique($permissions);
    }
213976
public function getPermission($action)
    {
        $action = strtoupper($action);
        if ($action == 'LIST') {
            return 'VIEW';
        } elseif ($action == 'SHOW') {
            return 'VIEW';
        } elseif ($action == 'NEW') {
            return 'CREATE';
        } elseif ($action == 'EDIT') {
            return 'EDIT';
        } elseif ($action == 'REMOVE') {
            return 'DELETE';
        }
        return $action;
    }
62395
private function getAllPermissions()
    {
        $user = auth()->user();

        if( $user->hasRole('admin') ) {
            $permissions = Permissions::select('id', 'name', 'action', 'created_at')->where('name', '!=', 'admin.acl.roles')->get();
        } elseif( $user->isSuperAdmin() ) {
            $permissions = Permissions::select('id', 'name', 'action', 'created_at')->get();
        } else {
            $permissions = collect([]);
        }

        $permissions = $permissions->sortBy('name')->groupBy('name');

        return json_encode($permissions);
    }
544359
public function getPermissionsViaRoles(): Collection
    {
        return $this->load('roles', 'roles.permissions')
            ->roles->flatMap(function ($role) {
                return $role->permissions;
            })->sort()->values();
    }
394003
public function rules()
    {
        $permission = Permission::find($this->route()->parameters['permission']);
        $permissionId = $permission->id;

        $rules = Permission::$rules;
        $rules['name'] = 'required|unique:z_permissions,name,' . $permissionId;
        return $rules;
    }
61613
public function getAllPermissionsForRole($role)
    {
        /** @var EloquentRole $role */
        $role = $this->getRole($role);

        if ( ! $role) {
            return [];
        }

        $permissions = array_keys(array_filter($role->getPermissions()));
        sort($permissions);

        return $permissions;
    }
887776
public function inferControllerAction($permission)
    {
        $area = null;
        if ($permission[0] === '/') {
            if ($areas = $this->router->getAreas()) {
                $pos = strpos($permission, '/', 1);
                $area = Text::camelize($pos === false ? substr($permission, 1) : substr($permission, 1, $pos - 1));
                if (in_array($area, $areas, true)) {
                    $permission = $pos === false || $pos === strlen($permission) - 1 ? '' : (string)substr($permission, $pos + 1);
                } else {
                    $area = null;
                    $permission = $permission === '/' ? '' : (string)substr($permission, 1);
                }
            } else {
                $permission = $permission === '/' ? '' : (string)substr($permission, 1);
            }
        } else {
            $area = $this->dispatcher->getArea();
        }

        if ($permission === '') {
            $controller = 'Index';
            $action = 'index';
        } elseif ($pos = strpos($permission, '/')) {
            if ($pos === false || $pos === strlen($permission) - 1) {
                $controller = Text::camelize($pos === false ? $permission : substr($permission, 0, -1));
                $action = 'index';
            } else {
                $controller = Text::camelize(substr($permission, 0, $pos));
                $action = lcfirst(Text::camelize(substr($permission, $pos + 1)));
            }
        } else {
            $controller = Text::camelize($permission);
            $action = 'index';
        }

        if ($area) {
            return ["@ns.app\\Areas\\$area\\Controllers\\{$controller}Controller", $action];
        } else {
            return ["@ns.app\\Controllers\\{$controller}Controller", $action];
        }
    }
846644
protected function checkPermission($permission = 'manage', $role = 'admin')
    {
        if ($this->auth->guest()) {
            return 401;
        }

        if ($this->auth->user()->can($permission) || $this->auth->user()->hasRole($role)) {
            return true;
        }

        return 403;
    }
1295760
public function getPermissionTable($userId)
    {
        if ($this->_permissionTable === null) {
            $this->_permissionTable = (new Query())
                ->select(['*'])
                ->from('{{%admin_user_group}}')
                ->innerJoin('{{%admin_group_auth}}', '{{%admin_user_group}}.group_id={{%admin_group_auth}}.group_id')
                ->innerJoin('{{%admin_auth}}', '{{%admin_group_auth}}.auth_id = {{%admin_auth}}.id')
                ->where(['{{%admin_user_group}}.user_id' => $userId])
                ->all();
        }
        
        return $this->_permissionTable;
    }
1337935
def get_permissions(self, role):
        """"""
        target_role = AuthGroup.objects(role=role, creator=self.client).first()
        if not target_role:
            return '[]'
        targets = AuthPermission.objects(groups=target_role, creator=self.client).only('name')
        return json.loads(targets.to_json())
1126177
public function getPermissions($string) : array
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId')
            ->setParameter('resourceClass', 'string')
            ->setParameter('resourceId', $string)
            ->getQuery();

        return $query->getResult();
    }
770478
private function getPermissionActions()
    {
        $actions = [];

        /**
         * @var $route \Symfony\Component\Routing\Route
         */
        foreach ($this->get('router')->getRouteCollection()->all() as $name => $route) {
            if ($route->hasOption('require_admin_permission')) {
                list(, $action) = explode('.', $route->getOption('require_admin_permission'));
                $actions[$action] = [
                    'id'   => $action,
                    'name' => $action
                ];
            }
        }

        ksort($actions);

        return array_values($actions);
    }
338233
public function rolesPermissions() {
    return [
      self::ROLE_USER => [
      ],
      self::ROLE_USER_MANAGER => [
        self::USER_VIEW,
        self::USER_CREATE,
        self::USER_UPDATE,
        self::USER_CHANGE_SECURITY_INFO,
        self::USER_CHANGE_PROFILE_INFO,
      ],
      self::ROLE_ADMIN => [
      ],
    ];
  }
1035308
protected function hasPermission()
    {
        $request = $this->request;
        $do = $this->getAction('can');

        return ! $this->forbiddenRoute() && $request->user()->can($do);
    }
149459
public function getPermissionActions()
    {
        $actions = [];

        /**
         * @var $route \Symfony\Component\Routing\Route
         */
        foreach ($this->router->getRouteCollection()->all() as $name => $route) {
            if ($route->hasOption('require_admin_permission')) {
                $options = explode('.', $route->getOption('require_admin_permission'));
                if (!array_key_exists($options[0], $actions))
                    $actions[$options[0]] = [];
                if (!in_array($options[1], $actions[$options[0]]))
                    $actions[$options[0]][] = $options[1];
            }
        }

        ksort($actions);

        return $actions;
    }