Return all the permissions the model has, both directly and via roles.

@throws \Exception
555429
public function getAllPermissions(): Collection
    {
        $permissions = $this->permissions;

        if ($this->roles) {
            $permissions = $permissions->merge($this->getPermissionsViaRoles());
        }

        return $permissions->sort()->values();
    }
377163
public function permissions()
    {
        return $this
            ->belongsToMany(
                config('laravel-auth.permissions.model', Permission::class),
                $this->getPrefix().config('laravel-auth.permission-role.table', 'permission_role')
            )
            ->using(Pivots\PermissionRole::class)
            ->withTimestamps();
    }
45521
public function getMergedPermissions(): array
    {
        $permissions = [];
        foreach ($this->getRoles() as $role) {
            $permissions = \array_merge($permissions, $role->getPermissions() ?? []);
        }

        // merge with users own permissions
        return \array_merge($permissions, $this->getPermissions());
    }
614000
private function getPermissions(): array
    {
        $model = App::shortName(get_class($this->table), 'Model/Table', 'Table');

        $values = $this->getPermissionsByModel($model);
        if (empty($values)) {
            return [];
        }

        $primaryKey = $this->table->getPrimaryKey();
        Assert::string($primaryKey);

        return [$this->table->aliasField($primaryKey) . ' IN' => array_unique($values)];
    }
106773
protected function getPermissions()
    {
        try {
            return $this->cache->rememberForever('permissions.policies', function () {
                return Permission::with('roles')->get();
            });
        } catch (\Exception $exception) {
            $this->cache->forget('permissions.policies');

            return new Collection;
        }
    }
1132607
public function getPermissionsAttribute()
    {
        return $this->active_roles
            ->pluck('permissions')
            ->flatten()
            ->unique(function (PermissionContract $permission) {
                return $permission->getKey();
            });
    }
10452
public function getRolesWithPermission($perm_id)
    {
        $roles = static::$app['db']->connection()
            ->table('roles_permissions')->where('permission_id', '=', $perm_id)->lists('role_id');

        $roles = array_map('intval', $roles);

        return $roles;
    }
1267677
public function perms()
    {
        return $this->belongsToMany(
            Config::get('ntrust.profiles.' . self::$roleProfile . '.permission'),
            Config::get('ntrust.profiles.' . self::$roleProfile . '.permission_role_table'),
            Config::get('ntrust.profiles.' . self::$roleProfile . '.role_foreign_key'),
            Config::get('ntrust.profiles.' . self::$roleProfile . '.permission_foreign_key'));
    }
898947
private function getAllMappedPermissions(): array
    {
        $mappedPermissions = [];
        foreach (Craft::$app->userPermissions->getAllPermissions() as $permissions) {
            $mappedPermissions = array_merge($mappedPermissions, $this->getMappedPermissions($permissions));
        }

        return $mappedPermissions;
    }
1004045
public function getPrettyPermissions() {
        $permissionReflect = new \ReflectionClass('\\pff\models\\'.$this->permissionClass);
        $prop = $permissionReflect->getProperties();
        $toReturnAnnotations = array();
        foreach($prop as $a) {
            $i = $this->reader->getPropertyAnnotations('\\pff\models\\'.$this->permissionClass, $a->name);
            $arr = $i->toArray();
            if(isset($arr['Pff2PermissionDescription'])){
                $tmp_name = explode('_', $a->name);
                array_walk($tmp_name, function(&$arr,$k){$arr = ucfirst($arr);});
                $toReturnAnnotations[implode($tmp_name)] = $arr['Pff2PermissionDescription'];
            }
        }
        return $toReturnAnnotations;
    }
939337
public function getAllPermissions()
    {

        $permissions = [];

        $roles = $this->group->roles()->with('permissions')->get();

        // Go through every role...
        foreach ($roles as $role) {

            // ... in every defined permission
            foreach ($role->permissions as $permission) {

                // only add permissions if it is not an inverse
                if (! $permission->pivot->not)
                    array_push($permissions, $permission->title);
            }

        }

        return $permissions;
    }
130335
public function getInheritedRolePermissions(Role $role)
    {
        $permissions = $this->getPermissionsForRole($role);

        if ($inheritedRole = $role->getInheritedRole()) {
            if ($inheritedRole = $this->manager->convertRoleToObject($inheritedRole)) {
                $permissions = array_merge($permissions, $this->getInheritedRolePermissions($inheritedRole));
            }
        }

        return $permissions;
    }
92809
public function getPermissions()
    {
        if (!$this->permissions) {
            $permissions = new Permissions('Job/Permissions');
            if ($this->user) {
                $permissions->grant($this->user, Permissions::PERMISSION_ALL);
            }
            $this->setPermissions($permissions);
        }

        return $this->permissions;
    }
1217462
public function rolePermissions()
    {

        $permissions = new Collection();
        foreach ($this->getRoles() as $role)
            $permissions = $permissions->merge($role->permissions);
        return $permissions;
    }
916460
public function allPermissions(callable $callable = null)
    {
        $permissionTable = $this->getPermissionableTable();
        $repository = $this->getRepository();

        $relation = $this->hasMany((new Entity($repository))->setTable($permissionTable))
                         ->foreignKey('id')
                         ->fill('allPermissions')
                         ->addSelect(['`' . $permissionTable . '`.*']);

        if ($callable) {
            $query = $relation->getRightEntity()->getQuery();

            Reflect::call(
                $callable,
                [
                    $query,
                    $relation,
                    $this,
                ]
            );
        }

        return $relation;
    }
161243
public function getPermissions()
    {
        // return permissions if they have already been requested
        if(Session::get("usersPermission")) {
            self::$permissions = Session::get("usersPermission");
            return Session::get("usersPermission");
        }
        // return permissions if they have already been requested
        if(self::$permissions) {
            return self::$permissions;
        }

        $groupIDs = [];
        foreach (Auth::user()->roles as $group) {
            if ($group->isDefault) {
                self::$permissions["global"]["isDefault"] = true;
            }
            $groupIDs[] = $group->groupID;
        }

        $permissions = Permission::whereIn("groupID", $groupIDs)->get();

        // save values in keys & values for easy access
        foreach ($permissions as $permission) {
            self::$permissions[$permission->app][$permission->key] = [
              'value' => ($permission->ids !== null) ? array_values(json_decode($permission->ids, true)) : $permission->value,
              'hasAll' => $permission['hasAll']
            ];
        }
        Session::put("usersPermission", self::$permissions);
        return self::$permissions;
    }
1084309
public function getRoles() {

		$roles = [];

		foreach($this -> permissions as $role => $permissions) {
			$roles[$role] = $this -> getRole($role);
		}

		return $roles;
	}