Get 'permissions' attribute.

@return Collection
490875
public function getPermissionsAttribute()
    {
        $permissions = new Collection();

        foreach ($this->roles as $role) {
            foreach ($role->permissions as $permission) {
                $permissions->push($permission);
            }
        }

        return $permissions;
    }
304323
public function getPermissions()
    {
        $registry = $this->getService('application.registry');
        $key = $this->getIdentifier().'-permissions';

        if (!$registry->offsetExists($key)) {
            $registry->offsetSet($key, self::_getDefaultPermissions($this));
        }

        return $registry->offsetGet($key);
    }
438395
public function allPermissions()
    {
        $roles = $this->roles()->with('permissions')->get();

        $roles = $roles->flatMap(function ($role) {
            return $role->permissions;
        });

        return $this->permissions()->get()->merge($roles)->unique('name');
    }
1135358
public function permissions() : BelongsToMany
    {
        $pivotTable = config('lia.database.user_permissions_table');

        $relatedModel = config('lia.database.permissions_model');

        return $this->belongsToMany($relatedModel, $pivotTable, 'user_id', 'permission_id');
    }
517314
protected function getPermissionsRole()
    {
        $arguments = $this->getArguments();

        if (count($arguments) < 2) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $role_id = array_shift($arguments);

        if (!is_numeric($role_id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        $role = $this->role->get($role_id);

        if (!isset($role['permissions'])) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($role_id, $role['permissions'], $arguments);
    }
410637
public function permissionSource() {
		if ($this->ParentID) {
			return $this->Parent();
		}
		if ($this->PermSourceID) {
			return $this->PermSource();
		}

		if ($this->ID && $this->Target && strpos($this->Target, ',')) {
			list($type, $id) = explode(',', $this->Target);
			$item = DataList::create($type)->byID($id);
			if ($item) {
				return $item;
			}
		}
	}
948352
public function listPermissions()
    {
        if ($this->permissionCache !== false) {
            return $this->permissionCache;
        }

        /*
         * Load module items
         */
        foreach ($this->callbacks as $callback) {
            $callback($this);
        }

        /*
         * Load plugin items
         */
        $plugins = PluginManager::instance()->getPlugins();

        foreach ($plugins as $id => $plugin) {
            $items = $plugin->registerPermissions();
            if (!is_array($items)) {
                continue;
            }

            $this->registerPermissions($id, $items);
        }

        /*
         * Sort permission items
         */
        usort($this->permissions, function ($a, $b) {
            if ($a->order == $b->order) {
                return 0;
            }

            return $a->order > $b->order ? 1 : -1;
        });

        return $this->permissionCache = $this->permissions;
    }
182017
protected function getFreshAllPermissions()
    {
        $permissionsRoles = $this->getRolesPermissions(true);

        $permissions = app('defender.permission')->getActivesByUser($this);

        $permissions = $permissions->merge($permissionsRoles)
            ->map(function ($permission) {
                unset($permission->pivot, $permission->created_at, $permission->updated_at);

                return $permission;
            });

        return $permissions->toBase();
    }
1038281
public function getPermissionsDescription()
    {
        if (class_exists(Subsite::class)) {
            Subsite::disable_subsite_filter(true);
        }

        $permissionsUsr = Permission::permissions_for_member($this->owner->ID);
        $permissionsSrc = Permission::get_codes(true);
        sort($permissionsUsr);

        $permissionNames = array();
        foreach ($permissionsUsr as $code) {
            $code = strtoupper($code);
            foreach ($permissionsSrc as $k => $v) {
                if (isset($v[$code])) {
                    $name = empty($v[$code]['name'])
                        ? _t(__CLASS__ . '.UNKNOWN', 'Unknown')
                        : $v[$code]['name'];
                    $permissionNames[] = $name;
                }
            }
        }

        $result = $permissionNames
            ? implode(', ', $permissionNames)
            : _t(__CLASS__ . '.NOPERMISSIONS', 'No Permissions');

        if (class_exists(Subsite::class)) {
            Subsite::disable_subsite_filter(false);
        }
        return $result;
    }
954512
protected function getFreshRolesPermissions()
    {
        $roles = $this->roles()->get(['id'])->pluck('id')->toArray();

        return app('defender.permission')->getByRoles($roles);
    }
615835
public function providePermissions()
    {
        $category = _t(__CLASS__ . '.PERMISSION_CATEGORY', 'SilverWare folders');
        
        return [
            'SILVERWARE_FOLDER_CREATE' => [
                'category' => $category,
                'name' => _t('.PERMISSION_CREATE_NAME', 'Create folders'),
                'help' => _t('.PERMISSION_CREATE_HELP', 'Ability to create SilverWare folders.'),
                'sort' => 100
            ],
            'SILVERWARE_FOLDER_EDIT' => [
                'category' => $category,
                'name' => _t('.PERMISSION_EDIT_NAME', 'Edit folders'),
                'help' => _t('.PERMISSION_EDIT_HELP', 'Ability to edit SilverWare folders.'),
                'sort' => 200
            ],
            'SILVERWARE_FOLDER_DELETE' => [
                'category' => $category,
                'name' => _t('.PERMISSION_DELETE_NAME', 'Delete folders'),
                'help' => _t('.PERMISSION_DELETE_HELP', 'Ability to delete SilverWare folders.'),
                'sort' => 300
            ]
        ];
    }
721639
public static function map()
    {
        $permissions = [];

        foreach (static::get() as $permission) {
            $permissions[$permission->permission][] = (string) $permission->group_id;
        }

        return $permissions;
    }
636615
protected static function get_permissions_name() {
        $strpermissions = array(
            CAP_INHERIT => get_string('inherit', 'role'),
            CAP_ALLOW => get_string('allow', 'role'),
            CAP_PREVENT => get_string('prevent', 'role'),
            CAP_PROHIBIT => get_string('prohibit', 'role')
        );
        return $strpermissions;
    }
11326
public function getPermissionsAttribute($permissions)
	{
		if ( ! $permissions)
		{
			return array();
		}

		if (is_array($permissions))
		{
			return $permissions;
		}

		if ( ! $_permissions = json_decode($permissions, true))
		{
			throw new \InvalidArgumentException("Cannot JSON decode permissions [$permissions].");
		}

		return $_permissions;
	}
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;
        }
    }
223690
protected function getCurrentFolderPermissions()
    {
        if ($this->currentFolderPermissions === null) {
            $folder = $this->getCurrentFolder();
            if ($folder === null) {
                $folder = $this->app->make(Filesystem::class)->getRootFolder();
                if ($folder === null) {
                    $folder = new FileFolder();
                }
            }
            $this->currentFolderPermissions = new Checker($folder);
        }

        return $this->currentFolderPermissions;
    }
659465
public function getUserRolePermissions()
  {
    $roles = Role::select('id', 'name', 'label')->get();
    $permissions = Permission::select('id', 'name', 'label')->get();
    return \View::make('admin.permissions.role-assign-permissions', [
      'roles'              =>  $roles,
      'permissions'        =>  $permissions,
      'title'              => 'assign',
    ]);
  }