Class · extends AbstractUser · implements ContactInterface, UserInterface
A client user.
The client is one of the most important records tracked by WHMCS. A client object models a single WHMCS customer. Clients can log into WHMCS's client area and can order services, create support tickets, or access all other functionality available in the client area. Their records contain contact information for the client, authentication and payment settings for the client, and other configuration options necessary for the client to properly use WHMCS.
Most objects stored in WHMCS are either directly related to a client or connected to a client through a client's related objects, such as invoices, orders, or quotes.
EmailPreferencesUserTrait
| Name | Description |
|---|---|
STATUS_ACTIVE | |
STATUS_INACTIVE | |
STATUS_CLOSED | |
PAYMENT_DATA_MIGRATED |
| Type | Name | Description |
|---|---|---|
| `` | $timestamps | |
| `` | $unique |
public function users()public function usersRelation()public function getUserIds()public function owner()Get owner.
Returns User\|null
public function invites()A client can have many invites.
Returns HasMany
public function domains()A client can have many domains.
Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Domain
public function services()A client can have many services.
Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Service
public function getEligibleOnDemandRenewalServices(): CollectionRetrieve list of Client's services that can be on-demand renewed
Returns Collection<ServiceOnDemandRenewalInterface>
public function getEligibleOnDemandRenewalServiceAddons(): CollectionRetrieve list of Client's service addons that can be on-demand renewed
Returns Collection<ServiceOnDemandRenewalInterface>
public function getOnDemandRenewalServices(): CollectionRetrieve list of Client's ServiceOnDemandRenewals regardless of renewal eligibility
Returns Collection<ServiceOnDemandRenewalInterface>
public function getEligibleOnDemandRenewalServiceIds(): CollectionThe service IDs only for Client's services that can be on-demand renewed
Returns Collection<int>
public function getEligibleOnDemandRenewalServiceAddonIds(): CollectionThe service addon IDs only for Client's service addons that can be on-demand renewed
Returns Collection<int>
public function hasItemsWithOnDemandRenewalCapability(): boolWhether the Client has Services or Addons that support the On-Demand Renewal feature.
Returns bool
public function addons()A client can have many add-on services.
Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Addon
public function contacts()A client can have many contacts.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function billingContact()Returns \Illuminate\Database\Eloquent\Relations\HasOne
public function quotes()A client can have many quotes for services.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function affiliate()A client can have an associated affiliate record.
Returns \Illuminate\Database\Eloquent\Relations\HasOne
public function invoices()A client can have many invoices.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function creditNotes()A client can have credit notes.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function debitNotes()A client can have debit notes.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function transactions()A client can have many transactions.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function group()A client can be assigned to a single Client Group
Returns null\|Group
public function formatter(): WHMCS\View\Admin\Formatter\Clientpublic function remoteAccountLinks()A client can have many linked remote accounts. NB: this will not return remote auth links of contacts associated with the client.
Returns \Illuminate\Database\Eloquent\Relations\HasMany
public function orders()A client can have many orders.
Returns HasMany
public function marketingConsent()Returns HasMany\|Consent
public function currencyrel()A client has an associated currency.
Named currencyrel because the name currency conflicts with field name.
Returns \Illuminate\Database\Eloquent\Relations\HasOne
public function scopeEmail($query, $email)Filter by email.
Parameters
| Type | Name | Description |
|---|---|---|
Builder | $query |
Returns Builder
public static function separateBillingCondition(): ClosureReturns a WHERE closure that matches clients or groups configured for separate invoicing. Requires tblclients and tblclientgroups to be joined in the outer query.
public function isOwnedBy(User $user): boolIs client owned by a given user?
Parameters
| Type | Name | Description |
|---|---|---|
User | $user |
Returns bool
public function getAutheduserAttribute()For backwards compat with six theme in v8.0.0
Returns \Stdclass
public function runPostLoginEvents()Executes post login of a client.
public static function getStatuses()Get client status values.
Returns string[]
public function hasDomain($domainName)Determines if client has a given domain name.
Checks for both domains associated to services as well as domain registrations.
Parameters
| Type | Name | Description |
|---|---|---|
string | $domainName |
Returns bool
public function getAlerts(AlertFactory $factory = null)Retrieve a client's alerts.
Parameters
| Type | Name | Description |
|---|---|---|
\WHMCS\User\Client\AlertFactory | $factory |
Returns \Illuminate\Support\Collection\|\WHMCS\User\Alert[]
public function isCreditCardExpiring($withinMonths = 2)Determine if a user's credit card is going to expire within a number of months.
Parameters
| Type | Name | Description |
|---|---|---|
int | $withinMonths |
Returns array\|false — An array with expiring credit card information
public function getPhoneNumberFormattedAttribute()Returns formatted phone number.
If PhoneNumberDropdown setting enabled, then phone number will be formatted to be digestable by jackocnr/intl-tel-input script used.
Returns string
public function getDisplayNameAttribute()public function getCountryNameAttribute()Returns the human readable name for the clients country.
Returns string
public function generateCreditCardEncryptedField($value)Generate an AES Encrypted string from the passed value.
Parameters
| Type | Name | Description |
|---|---|---|
string | $value |
Returns string
public function getUsernameAttribute()public function hasSingleSignOnPermission()Returns if the client has Single Sign-On Enabled for their account.
Returns bool
public function isAllowedToAuthenticate()Should the user be allowed to authenticate
Returns bool
public function isEmailAddressVerified()Returns if the clients' owners email address is verified.
Returns bool
public function updateLastLogin(Carbon $time = null, $ip = null, $host = null)public function customFieldValues()Returns HasMany\|CustomFieldValue
public function hasPermission($permission)This fulfills the UserInterface
Parameters
| Type | Name | Description |
|---|---|---|
string|int | $permission |
Returns bool
public function tickets()A client can have many tickets.
Returns HasMany
public function isOptedInToMarketingEmails()Determine if user is opted in to marketing emails.
Returns bool
public function marketingEmailOptIn($userIp = '', $performCurrentSettingCheck = true)Opt in to email marketing.
Parameters
| Type | Name | Description |
|---|---|---|
string | $userIp | |
bool | $performCurrentSettingCheck |
Returns self
public function marketingEmailOptOut($userIp = '', $performCurrentSettingCheck = true)Opt out of email marketing.
Parameters
| Type | Name | Description |
|---|---|---|
string | $userIp | |
bool | $performCurrentSettingCheck |
Returns self
public function logActivity($message)Log activity.
Parameters
| Type | Name | Description |
|---|---|---|
string | $message |
Returns self
public function closeClient(): voidCloses a Client Account and cancels associated data.
public function deleteEntireClient(): ?boolDeletes a client and all associated data.
Returns bool\|null
public static function getGroups()public function needsCardDetailsMigrated()public function needsBankDetailsMigrated()public function needsUnknownPaymentTokenMigrated()public function needsAnyPaymentDetailsMigrated()public function migratePaymentDetailsIfRequired($forceInCron = false)public function markCardDetailsAsMigrated()public function markBankDetailsAsMigrated()public function markPaymentTokenMigrated()public function payMethods()Returns HasMany
public function defaultBillingContact()Return a model of the billing contact or the client itself
This is determined by a value set against billingcid.
Returns HasOne\|BelongsTo
public function getGroupNameAttribute()Returns string
public function domainSslStatuses()Returns HasMany
public function generateUniquePlaceholderEmail()public function deleteAllCreditCards()public static function getUsedCardTypes()Get the card types currently used.
Returns array
public function buildBillingContactsArray()Returns array
public function createRemoteCardPayMethod($gateway, $cardNumber, $cardExpiryDate, $remoteToken, $billingContactId = 'billing', $description = '', $cardType = null, $cardStartDate = null, $cardIssueNumber = null)Parameters
| Type | Name | Description |
|---|---|---|
string|Gateway | $gateway | The gateway to store the Pay Method against |
string | $cardNumber | The card number (or last 4 digits). Full card number will not be stored. |
string | $cardExpiryDate | Card expiry date in mmyy format. |
string | $remoteToken | The remote token for the pay method. |
string|integer | $billingContactId | The id of the billing contact to use. |
string | $description | The description for the new pay method. |
null|string | $cardType | The card type to use. Null will attempt to get card type from card number. |
null|string | $cardStartDate | Optional. Card start date in mmyy format. |
null|string | $cardIssueNumber | Optional. The issue number for the card. |
Returns PayMethodInterface
public function createCardPayMethod($cardNumber, $cardExpiryDate, $billingContactId = 'billing', $description = '', $cardType = null, $cardStartDate = null, $cardIssueNumber = null)Parameters
| Type | Name | Description |
|---|---|---|
string | $cardNumber | The card number (or last 4 digits). Full card number will not be stored. |
string | $cardExpiryDate | Card expiry date in mmyy format. |
string|integer | $billingContactId | The id of the billing contact to use. |
string | $description | The description for the new pay method. |
null|string | $cardType | The card type to use. Null will attempt to get card type from card number. |
null|string | $cardStartDate | Optional. Card start date in mmyy format. |
null|string | $cardIssueNumber | Optional. The issue number for the card. |
Returns PayMethodInterface
public function createBankPayMethod($accountType, $routingNumber, $accountNumber, $bankName, $accountHolderName, $billingContactId = 'billing', $description = '')Parameters
| Type | Name | Description |
|---|---|---|
string | $accountType | A type, such as checking or savings |
string | $routingNumber | Bank routing number |
string | $accountNumber | Bank account number |
string | $bankName | Name of bank the account belongs to |
string | $accountHolderName | Name of the account holder |
string|integer | $billingContactId | The id of the billing contact to use. |
string | $description | The description for the new pay method. |
Returns PayMethodInterface
public function createRemoteBankPayMethod($gateway, $remoteToken, $accountNumber = '', $accountHolderName = '', $billingContactId = 'billing', $description = '')Parameters
| Type | Name | Description |
|---|---|---|
string|Gateway | $gateway | The gateway to store the Pay Method against |
string | $remoteToken | The remote token for a remote bank account. |
string | $accountNumber | Bank account number |
string | $accountHolderName | Name of the account holder |
string|integer | $billingContactId | The id of the billing contact to use. |
string | $description | The description for the new pay method. |
Returns PayMethodInterface
public function getClientDiscountPercentage()Get client discount percentage.
Returns float
public function addCredit($description, $amount)Add a credit + credit log entry.
Parameters
| Type | Name | Description |
|---|---|---|
string | $description | |
float | $amount |
Returns self
public function getLink()public function authedUserIsOwner()public function getAuthUserById($userId)public function getCurrencyCodeAttribute(): stringpublic function mergeTo(Client $client): selfpublic function deleteUsersWithNoOtherClientAccounts(): voidDelete all users related to this account that have no relationship to any other account.
This should only be called when deleting a client account.
public function deleteTransactions(): voidDelete all transactions belonging to this account
public function disassociateTransactions(): voidDisassociate all transactions from this account.
This removes the account association and sets the currency id to match the current from this account.
public function getDisplayNameFormattedAttribute(): stringpublic function subscriptions(array $paymentGatewayIdentifiers = []): ClientSubscriptionServices