Skip to content
Last updated

WHMCS\User\Admin

Class · extends AbstractUser · implements UserInterface

An administrative user

An administrative user is responsible for operation and maintenance of a WHMCS installation. Admins have access to create and manage clients clients, place orders, configure WHMCS, manage modules, and can access all of WHMCS's high level systems. Their accounts can log into the WHMCS client area, and like clients, can be configured to use two-factor authentication modules.

This object models an admin's record in the backend database and contains the admin's information and personal settings. phpcs:disable

Traits

  • Authenticatable
  • UserTrait

Constants

NameDescription
TEMPLATE_THEME_DEFAULT
MAXIMUM_PASSWORD_LENGTH

Properties

TypeNameDescription
``$unique

Methods

getSecondFactorModuleName

public function getSecondFactorModuleName()

getSecondFactorConfigName

public function getSecondFactorConfigName()

getFullNameAttribute

public function getFullNameAttribute()

"fullName" is the concatenation of first and last name.

In classic WHMCS objects, we compute a field named "name" which combines the first and last name for convenience in templates.

Returns string — The combined name

getGravatarHashAttribute

public function getGravatarHashAttribute()

Get gravatar email address hash.

Returns string

getUsernameAttribute

public function getUsernameAttribute()

Return the username

This method is required by the UserInterface. tbladmins has a username column, and thus a $username property, however, this model method will prevent the normal model access to that, so the method must manual fetch the value from the internal attributes property. Otherwise a NOTICE will be emitted.

Returns string

isAllowedToAuthenticate

public function isAllowedToAuthenticate()

Should the user be allowed to authenticate

Returns bool

isAllowedToMasquerade

public function isAllowedToMasquerade()

Returns bool

hasPermission

public function hasPermission($permission)

Has a given permission within their assigned role group

Parameters

TypeNameDescription
int|string$permissionEither the permission name or the permission id

Returns bool

getRoleName

public function getRoleName()

Get assigned admin role group name.

Returns string

getRolePermissions

public function getRolePermissions()

Array of permission names available to this admin user

Returns array

getModulePermissions

public function getModulePermissions()

Returns array

authenticationDevices

public function authenticationDevices()

Returns \Illuminate\Database\Eloquent\Relations\HasMany

getTemplateThemeNameAttribute

public function getTemplateThemeNameAttribute()

Returns string

validateUsername

public function validateUsername($username, $existingUserId = null)

Validate admin username is valid.

Optionally also validate it is unique. Requires passing in of existing admin user ID or 0 for a new admin user creation.

Parameters

TypeNameDescription
string$username
int|null$existingUserIdOptional, pass to validate uniqueness

flaggedTickets

public function flaggedTickets()

An admin can have many flagged tickets.

Returns HasMany

scopeActive

public function scopeActive(Builder $query)

Return only active Admin users

Parameters

TypeNameDescription
Builder$query

Returns Builder

getAuthenticatedUser

public static function getAuthenticatedUser()

Get the currently authenticated admin user.

Returns self\|null

getSupportDepartmentIds

public function getSupportDepartmentIds()

Get support department ids.

Returns int[]

setSecondFactorConfig

public function setSecondFactorConfig(array $value): self

getAuthIdentifierName

public function getAuthIdentifierName()