Get the authority, creating a role authority if necessary.

@return \Illuminate\Database\Eloquent\Model|null
359069
protected function getAuthority()
    {
        if (is_null($this->authority)) {
            return null;
        }

        if ($this->authority instanceof Model) {
            return $this->authority;
        }

        return Models::role()->firstOrCreate(['name' => $this->authority]);
    }
1087516
public function getSecurityModel()
    {
        if ($this->security_model)
            return $this->security_model;
        elseif ($this->getParent())
            return $this->getParent()->getSecurityModel();
        else
            return null;
    }
563740
public function getPermissionAccessObject()
    {
        if ($this->permissionObjectToCheck instanceof Area) {
            $app = Application::getFacadeApplication();
            $db = $app->make(Connection::class);
            $r = $db->fetchColumn(
                'select paID from AreaPermissionAssignments where cID = ? and arHandle = ? and pkID = ? ',
                [
                    $this->permissionObjectToCheck->getCollectionID(),
                    $this->permissionObjectToCheck->getAreaHandle(),
                    $this->pk->getPermissionKeyID(),
                ]
            );
            if ($r) {
                return Access::getByID($r, $this->pk, false);
            }
        } elseif (isset($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()])) {
            // this is a page
            $pk = PermissionKey::getByHandle($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()]);
            $pk->setPermissionObject($this->permissionObjectToCheck);
            $pae = $pk->getPermissionAccessObject();

            return $pae;
        } elseif (isset($this->blockTypeInheritedPermissions[$this->pk->getPermissionKeyHandle()])) {
            $pk = PermissionKey::getByHandle($this->blockTypeInheritedPermissions[$this->pk->getPermissionKeyHandle()]);
            $pae = $pk->getPermissionAccessObject();

            return $pae;
        }

        return null;
    }
658095
public function getAuthor()
    {
        if ($this->author === null) {
            $this->author = $this->authorFactory->create($this->getAuthorId());
        }

        return $this->author;
    }
358762
public function getAuthority(): string
    {
        if ($this->host == '') {
            return '';
        }

        $authority = $this->host;
        if ($this->user != '') {
            $authority = $this->user.'@'.$authority;
        }

        if ($this->port !== null && !$this->isDefaultPort($this->scheme, $this->port)) {
            $authority .= ':'.$this->port;
        }

        return $authority;
    }
1245820
public function getRoleService()
    {
        if ($this->roleService !== null) {
            return $this->roleService;
        }

        $this->roleService = new RoleService(
            $this,
            $this->persistenceHandler->userHandler(),
            $this->getLimitationService(),
            $this->getRoleDomainMapper(),
            $this->serviceSettings['role']
        );

        return $this->roleService;
    }
560366
public function getRoles()
    {
        $roles = $this->getExplicitRoles();

        if (!$roles) {
            return null;
        }

        $finalRoles = array();
        foreach ($roles as $role) {
            $childRoles = $role->getChildRoles();

            foreach ($childRoles as $childRole) {
                if (!in_array($childRole, $finalRoles)) {
                    $finalRoles[] = $childRole;
                }
            }

            if (!in_array($role, $finalRoles)) {
                $finalRoles[] = $role;
            }
        }

        return $finalRoles;
    }
745708
public function getRole() : ?string 
    {
        if ( ! $this->hasRole()) {
            $this->setRole($this->getDefaultRole());
        }
        return $this->role;
    }
1035832
public function getRole()
    {
        $id = $this->getId();

        if (strpos($id, 'ROLE_') === 0) {
            return strtoupper($id);
        }

        return strtoupper('ROLE_' . $this->getId());
    }
556562
public function getUserAgent()
    {
        if ($this->USER_AGENT) {
            return $this->USER_AGENT;
        }

        if ($this->HTTP_USER_AGENT) {
            return $this->HTTP_USER_AGENT;
        }

        return null;
    }
705262
public function getAccessToken()
    {
        $accessTokenAttribute = $this->accessTokenAttribute;
        return (is_string($accessTokenAttribute) && !empty($accessTokenAttribute)) ? $this->$accessTokenAttribute : null;
    }
1175250
private function setAuthority(): ?string
    {
        $authority = null;
        if (null !== $this->user_info) {
            $authority = $this->user_info.'@';
        }

        if (null !== $this->host) {
            $authority .= $this->host;
        }

        if (null !== $this->port) {
            $authority .= ':'.$this->port;
        }

        return $authority;
    }
1191123
public function roles()
    {
        return $this->belongsToMany(
                config('laravel-auth.roles.model', Role::class),
                $this->getPrefix().config('laravel-auth.role-user.table', 'role_user')
            )
            ->using(Pivots\RoleUser::class)
            ->withTimestamps();
    }
576502
public function getPrimaryModel() {
        if ($model = $this->_model) {
            return $model;
        }

        $class = $this->getPrimaryClass();

        if (!$class) {
            return null;
        }

        $this->setPrimaryModel(new $class());

        return $this->_model;
    }
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);
    }
844463
public function canOauthorize()
    {
        $api = $this->getAPI();
        
        if ($api && $this->actor) {
            return $api->canAddService($this->actor);
        }

        return !is_null($api);
    }
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();
    }