Skip to content
Last updated

WHMCS\User\Client

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.

Traits

  • EmailPreferences
  • UserTrait

Constants

NameDescription
STATUS_ACTIVE
STATUS_INACTIVE
STATUS_CLOSED
PAYMENT_DATA_MIGRATED

Properties

TypeNameDescription
``$timestamps
``$unique

Methods

users

public function users()

usersRelation

public function usersRelation()

getUserIds

public function getUserIds()

owner

public function owner()

Get owner.

Returns User\|null

invites

public function invites()

A client can have many invites.

Returns HasMany

domains

public function domains()

A client can have many domains.

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Domain

services

public function services()

A client can have many services.

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Service

getEligibleOnDemandRenewalServices

public function getEligibleOnDemandRenewalServices(): Collection

Retrieve list of Client's services that can be on-demand renewed

Returns Collection<ServiceOnDemandRenewalInterface>

getEligibleOnDemandRenewalServiceAddons

public function getEligibleOnDemandRenewalServiceAddons(): Collection

Retrieve list of Client's service addons that can be on-demand renewed

Returns Collection<ServiceOnDemandRenewalInterface>

getOnDemandRenewalServices

public function getOnDemandRenewalServices(): Collection

Retrieve list of Client's ServiceOnDemandRenewals regardless of renewal eligibility

Returns Collection<ServiceOnDemandRenewalInterface>

getEligibleOnDemandRenewalServiceIds

public function getEligibleOnDemandRenewalServiceIds(): Collection

The service IDs only for Client's services that can be on-demand renewed

Returns Collection<int>

getEligibleOnDemandRenewalServiceAddonIds

public function getEligibleOnDemandRenewalServiceAddonIds(): Collection

The service addon IDs only for Client's service addons that can be on-demand renewed

Returns Collection<int>

hasItemsWithOnDemandRenewalCapability

public function hasItemsWithOnDemandRenewalCapability(): bool

Whether the Client has Services or Addons that support the On-Demand Renewal feature.

Returns bool

addons

public function addons()

A client can have many add-on services.

Returns \Illuminate\Database\Eloquent\Relations\HasMany\|Addon

contacts

public function contacts()

A client can have many contacts.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

billingContact

public function billingContact()

Returns \Illuminate\Database\Eloquent\Relations\HasOne

quotes

public function quotes()

A client can have many quotes for services.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

affiliate

public function affiliate()

A client can have an associated affiliate record.

Returns \Illuminate\Database\Eloquent\Relations\HasOne

invoices

public function invoices()

A client can have many invoices.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

creditNotes

public function creditNotes()

A client can have credit notes.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

debitNotes

public function debitNotes()

A client can have debit notes.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

transactions

public function transactions()

A client can have many transactions.

Returns \Illuminate\Database\Eloquent\Relations\HasMany

group

public function group()

A client can be assigned to a single Client Group

Returns null\|Group

formatter

public function formatter(): WHMCS\View\Admin\Formatter\Client
public 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

orders

public function orders()

A client can have many orders.

Returns HasMany

marketingConsent

public function marketingConsent()

Returns HasMany\|Consent

currencyrel

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

scopeEmail

public function scopeEmail($query, $email)

Filter by email.

Parameters

TypeNameDescription
Builder$query

Returns Builder

separateBillingCondition

public static function separateBillingCondition(): Closure

Returns a WHERE closure that matches clients or groups configured for separate invoicing. Requires tblclients and tblclientgroups to be joined in the outer query.

isOwnedBy

public function isOwnedBy(User $user): bool

Is client owned by a given user?

Parameters

TypeNameDescription
User$user

Returns bool

getAutheduserAttribute

public function getAutheduserAttribute()

For backwards compat with six theme in v8.0.0

Returns \Stdclass

runPostLoginEvents

public function runPostLoginEvents()

Executes post login of a client.

getStatuses

public static function getStatuses()

Get client status values.

Returns string[]

hasDomain

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

TypeNameDescription
string$domainName

Returns bool

getAlerts

public function getAlerts(AlertFactory $factory = null)

Retrieve a client's alerts.

Parameters

TypeNameDescription
\WHMCS\User\Client\AlertFactory$factory

Returns \Illuminate\Support\Collection\|\WHMCS\User\Alert[]

isCreditCardExpiring

public function isCreditCardExpiring($withinMonths = 2)

Determine if a user's credit card is going to expire within a number of months.

Parameters

TypeNameDescription
int$withinMonths

Returns array\|false — An array with expiring credit card information

getPhoneNumberFormattedAttribute

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

getDisplayNameAttribute

public function getDisplayNameAttribute()

getCountryNameAttribute

public function getCountryNameAttribute()

Returns the human readable name for the clients country.

Returns string

generateCreditCardEncryptedField

public function generateCreditCardEncryptedField($value)

Generate an AES Encrypted string from the passed value.

Parameters

TypeNameDescription
string$value

Returns string

getUsernameAttribute

public function getUsernameAttribute()

hasSingleSignOnPermission

public function hasSingleSignOnPermission()

Returns if the client has Single Sign-On Enabled for their account.

Returns bool

isAllowedToAuthenticate

public function isAllowedToAuthenticate()

Should the user be allowed to authenticate

Returns bool

isEmailAddressVerified

public function isEmailAddressVerified()

Returns if the clients' owners email address is verified.

Returns bool

updateLastLogin

public function updateLastLogin(Carbon $time = null, $ip = null, $host = null)

customFieldValues

public function customFieldValues()

Returns HasMany\|CustomFieldValue

hasPermission

public function hasPermission($permission)

This fulfills the UserInterface

Parameters

TypeNameDescription
string|int$permission

Returns bool

tickets

public function tickets()

A client can have many tickets.

Returns HasMany

isOptedInToMarketingEmails

public function isOptedInToMarketingEmails()

Determine if user is opted in to marketing emails.

Returns bool

marketingEmailOptIn

public function marketingEmailOptIn($userIp = '', $performCurrentSettingCheck = true)

Opt in to email marketing.

Parameters

TypeNameDescription
string$userIp
bool$performCurrentSettingCheck

Returns self

marketingEmailOptOut

public function marketingEmailOptOut($userIp = '', $performCurrentSettingCheck = true)

Opt out of email marketing.

Parameters

TypeNameDescription
string$userIp
bool$performCurrentSettingCheck

Returns self

logActivity

public function logActivity($message)

Log activity.

Parameters

TypeNameDescription
string$message

Returns self

closeClient

public function closeClient(): void

Closes a Client Account and cancels associated data.

deleteEntireClient

public function deleteEntireClient(): ?bool

Deletes a client and all associated data.

Returns bool\|null

getGroups

public static function getGroups()

needsCardDetailsMigrated

public function needsCardDetailsMigrated()

needsBankDetailsMigrated

public function needsBankDetailsMigrated()

needsUnknownPaymentTokenMigrated

public function needsUnknownPaymentTokenMigrated()

needsAnyPaymentDetailsMigrated

public function needsAnyPaymentDetailsMigrated()

migratePaymentDetailsIfRequired

public function migratePaymentDetailsIfRequired($forceInCron = false)

markCardDetailsAsMigrated

public function markCardDetailsAsMigrated()

markBankDetailsAsMigrated

public function markBankDetailsAsMigrated()

markPaymentTokenMigrated

public function markPaymentTokenMigrated()

payMethods

public function payMethods()

Returns HasMany

defaultBillingContact

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

getGroupNameAttribute

public function getGroupNameAttribute()

Returns string

domainSslStatuses

public function domainSslStatuses()

Returns HasMany

generateUniquePlaceholderEmail

public function generateUniquePlaceholderEmail()

deleteAllCreditCards

public function deleteAllCreditCards()

getUsedCardTypes

public static function getUsedCardTypes()

Get the card types currently used.

Returns array

buildBillingContactsArray

public function buildBillingContactsArray()

Returns array

createRemoteCardPayMethod

public function createRemoteCardPayMethod($gateway, $cardNumber, $cardExpiryDate, $remoteToken, $billingContactId = 'billing', $description = '', $cardType = null, $cardStartDate = null, $cardIssueNumber = null)

Parameters

TypeNameDescription
string|Gateway$gatewayThe gateway to store the Pay Method against
string$cardNumberThe card number (or last 4 digits). Full card number will not be stored.
string$cardExpiryDateCard expiry date in mmyy format.
string$remoteTokenThe remote token for the pay method.
string|integer$billingContactIdThe id of the billing contact to use.
string$descriptionThe description for the new pay method.
null|string$cardTypeThe card type to use. Null will attempt to get card type from card number.
null|string$cardStartDateOptional. Card start date in mmyy format.
null|string$cardIssueNumberOptional. The issue number for the card.

Returns PayMethodInterface

createCardPayMethod

public function createCardPayMethod($cardNumber, $cardExpiryDate, $billingContactId = 'billing', $description = '', $cardType = null, $cardStartDate = null, $cardIssueNumber = null)

Parameters

TypeNameDescription
string$cardNumberThe card number (or last 4 digits). Full card number will not be stored.
string$cardExpiryDateCard expiry date in mmyy format.
string|integer$billingContactIdThe id of the billing contact to use.
string$descriptionThe description for the new pay method.
null|string$cardTypeThe card type to use. Null will attempt to get card type from card number.
null|string$cardStartDateOptional. Card start date in mmyy format.
null|string$cardIssueNumberOptional. The issue number for the card.

Returns PayMethodInterface

createBankPayMethod

public function createBankPayMethod($accountType, $routingNumber, $accountNumber, $bankName, $accountHolderName, $billingContactId = 'billing', $description = '')

Parameters

TypeNameDescription
string$accountTypeA type, such as checking or savings
string$routingNumberBank routing number
string$accountNumberBank account number
string$bankNameName of bank the account belongs to
string$accountHolderNameName of the account holder
string|integer$billingContactIdThe id of the billing contact to use.
string$descriptionThe description for the new pay method.

Returns PayMethodInterface

createRemoteBankPayMethod

public function createRemoteBankPayMethod($gateway, $remoteToken, $accountNumber = '', $accountHolderName = '', $billingContactId = 'billing', $description = '')

Parameters

TypeNameDescription
string|Gateway$gatewayThe gateway to store the Pay Method against
string$remoteTokenThe remote token for a remote bank account.
string$accountNumberBank account number
string$accountHolderNameName of the account holder
string|integer$billingContactIdThe id of the billing contact to use.
string$descriptionThe description for the new pay method.

Returns PayMethodInterface

getClientDiscountPercentage

public function getClientDiscountPercentage()

Get client discount percentage.

Returns float

addCredit

public function addCredit($description, $amount)

Add a credit + credit log entry.

Parameters

TypeNameDescription
string$description
float$amount

Returns self

public function getLink()

authedUserIsOwner

public function authedUserIsOwner()

getAuthUserById

public function getAuthUserById($userId)

getCurrencyCodeAttribute

public function getCurrencyCodeAttribute(): string

mergeTo

public function mergeTo(Client $client): self

deleteUsersWithNoOtherClientAccounts

public function deleteUsersWithNoOtherClientAccounts(): void

Delete all users related to this account that have no relationship to any other account.

This should only be called when deleting a client account.

deleteTransactions

public function deleteTransactions(): void

Delete all transactions belonging to this account

disassociateTransactions

public function disassociateTransactions(): void

Disassociate all transactions from this account.

This removes the account association and sets the currency id to match the current from this account.

getDisplayNameFormattedAttribute

public function getDisplayNameFormattedAttribute(): string

subscriptions

public function subscriptions(array $paymentGatewayIdentifiers = []): ClientSubscriptionServices