Admin
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
Constants
TEMPLATE_THEME_DEFAULT |
|
Properties summary
Type | Property | Description | |
---|---|---|---|
protected | $table | ||
protected | $columnMap | ||
$unique | |||
protected | $appends | ||
protected | $commaSeparated | ||
protected | $rules | ||
$hidden | |||
int | $id | An admin's unique id number. | |
int | $roleId | ID number of this admin's role. (Role based permissions) | |
string | $username | An admin's username. | |
string | $passwordHash | An admin's stored password hash. | |
string | $twoFactorAuthModule | The name of an admin's two factor authentication module, if they are using one. | |
string | $twoFactorAuthData | An admin's two-factor authentication module's internal data, stored as a PHP serialized string. | |
string | $firstName | An admin's first name. | |
string | $lastName | An admin's last name. | |
string | An admin's email address. | ||
string | $signature | A message displayed at the bottom of an admin's support ticket responses. | |
string | $notes | An internal note available for an admin's general use. | |
string | $template | The name of the admin area view template WHMCS renders for an admin. | |
string | $language | An admin's preferred display language. | |
int | $isDisabled | Whether or not an admin is disabled and cannot log in. | |
int | $loginAttempts | The number of times an admin has failed to log into the WHMCS admin area. | |
array | $supportDepartmentIds | The id numbers of the support departments an admin is assigned to. | |
array | $receivesTicketNotifications | Whether or not an admin receives an email on new support ticket or support ticket reply creation. | |
string | $homeWidgets | A comma delimited list of legacy admin area home page widgets and their configuration, separated by colons. For instance, widget_name:true/false | |
string | $passwordResetKey | The password reset key for an admin user when requested | |
string | $passwordResetData | The password reset data for an admin user when requested | |
Carbon | $passwordResetExpiry | The expiry for the password reset key for an admin user | |
$hiddenWidgets | The widgets hidden for the Admin user | ||
string[] | $widgetOrder | The display order for widgets for the Admin user | |
Collection|Ticket[] | $flaggedTickets | ||
string | $fullName | An admin's first name and last name. | |
string | $gravatarHash | The hash for the gravatar url | |
string | $templateThemeName | alias for $template |
Methods summary
Return Type | Method Name | Description | |
---|---|---|---|
string | getFullNameAttribute() | "fullName" is the concatenation of first and last name. | |
string | getGravatarHashAttribute() | Get gravatar email address hash. | |
string | getUsernameAttribute() | Return the username | |
bool | isAllowedToAuthenticate() | Should the user be allowed to authenticate | |
bool | isAllowedToMasquerade() | - | |
bool | hasPermission(int|string $permission) | Has a given permission within their assigned role group | |
array | getRolePermissions() | Array of permission names available to this admin user | |
array | getModulePermissions() | - | |
HasMany | authenticationDevices() | - | |
string | getTemplateThemeNameAttribute() | - | |
validateUsername(string $username, int|null $existingUserId = null) | Validate admin username is valid. | ||
HasMany | flaggedTickets() | An admin can have many flagged tickets. | |
Builder | scopeActive(Builder $query) | Return only active Admin users | |
static Admin|null | getAuthenticatedUser() | Get the currently authenticated admin user. |
Details
string
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.
string
getGravatarHashAttribute ()
Get gravatar email address hash.
string
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.
bool
isAllowedToAuthenticate ()
Should the user be allowed to authenticate
bool
isAllowedToMasquerade ()
bool
hasPermission (int|string $permission)
Has a given permission within their assigned role group
array
getRolePermissions ()
Array of permission names available to this admin user
array
getModulePermissions ()
HasMany
authenticationDevices ()
string
getTemplateThemeNameAttribute ()
validateUsername (string $username, int|null $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.
HasMany
flaggedTickets ()
An admin can have many flagged tickets.
Builder
scopeActive (Builder $query)
Return only active Admin users
static Admin|null
getAuthenticatedUser ()
Get the currently authenticated admin user.