# 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

| Name | Description |
|  --- | --- |
| `STATUS_ACTIVE` |  |
| `STATUS_INACTIVE` |  |
| `STATUS_CLOSED` |  |
| `PAYMENT_DATA_MIGRATED` |  |


## Properties

| Type | Name | Description |
|  --- | --- | --- |
| `` | `$timestamps` |  |
| `` | `$unique` |  |


## Methods

### users

```php
public function users()
```

### usersRelation

```php
public function usersRelation()
```

### getUserIds

```php
public function getUserIds()
```

### owner

```php
public function owner()
```

Get owner.

**Returns** `User\|null`

### invites

```php
public function invites()
```

A client can have many invites.

**Returns** `HasMany`

### domains

```php
public function domains()
```

A client can have many domains.

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

### services

```php
public function services()
```

A client can have many services.

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

### getEligibleOnDemandRenewalServices

```php
public function getEligibleOnDemandRenewalServices(): Collection
```

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

**Returns** `Collection<ServiceOnDemandRenewalInterface>`

### getEligibleOnDemandRenewalServiceAddons

```php
public function getEligibleOnDemandRenewalServiceAddons(): Collection
```

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

**Returns** `Collection<ServiceOnDemandRenewalInterface>`

### getOnDemandRenewalServices

```php
public function getOnDemandRenewalServices(): Collection
```

Retrieve list of Client's ServiceOnDemandRenewals regardless of renewal eligibility

**Returns** `Collection<ServiceOnDemandRenewalInterface>`

### getEligibleOnDemandRenewalServiceIds

```php
public function getEligibleOnDemandRenewalServiceIds(): Collection
```

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

**Returns** `Collection<int>`

### getEligibleOnDemandRenewalServiceAddonIds

```php
public function getEligibleOnDemandRenewalServiceAddonIds(): Collection
```

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

**Returns** `Collection<int>`

### hasItemsWithOnDemandRenewalCapability

```php
public function hasItemsWithOnDemandRenewalCapability(): bool
```

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

**Returns** `bool`

### addons

```php
public function addons()
```

A client can have many add-on services.

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

### contacts

```php
public function contacts()
```

A client can have many contacts.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### billingContact

```php
public function billingContact()
```

**Returns** `\Illuminate\Database\Eloquent\Relations\HasOne`

### quotes

```php
public function quotes()
```

A client can have many quotes for services.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### affiliate

```php
public function affiliate()
```

A client can have an associated affiliate record.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasOne`

### invoices

```php
public function invoices()
```

A client can have many invoices.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### creditNotes

```php
public function creditNotes()
```

A client can have credit notes.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### debitNotes

```php
public function debitNotes()
```

A client can have debit notes.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### transactions

```php
public function transactions()
```

A client can have many transactions.

**Returns** `\Illuminate\Database\Eloquent\Relations\HasMany`

### group

```php
public function group()
```

A client can be assigned to a single Client Group

**Returns** `null\|Group`

### formatter

```php
public function formatter(): WHMCS\View\Admin\Formatter\Client
```

### remoteAccountLinks

```php
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

```php
public function orders()
```

A client can have many orders.

**Returns** `HasMany`

### marketingConsent

```php
public function marketingConsent()
```

**Returns** `HasMany\|Consent`

### currencyrel

```php
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

```php
public function scopeEmail($query, $email)
```

Filter by email.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `Builder` | `$query` |  |


**Returns** `Builder`

### separateBillingCondition

```php
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

```php
public function isOwnedBy(User $user): bool
```

Is client owned by a given user?

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `User` | `$user` |  |


**Returns** `bool`

### getAutheduserAttribute

```php
public function getAutheduserAttribute()
```

For backwards compat with six theme in v8.0.0

**Returns** `\Stdclass`

### runPostLoginEvents

```php
public function runPostLoginEvents()
```

Executes post login of a client.

### getStatuses

```php
public static function getStatuses()
```

Get client status values.

**Returns** `string[]`

### hasDomain

```php
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`

### getAlerts

```php
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[]`

### isCreditCardExpiring

```php
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

### getPhoneNumberFormattedAttribute

```php
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

```php
public function getDisplayNameAttribute()
```

### getCountryNameAttribute

```php
public function getCountryNameAttribute()
```

Returns the human readable name for the clients country.

**Returns** `string`

### generateCreditCardEncryptedField

```php
public function generateCreditCardEncryptedField($value)
```

Generate an AES Encrypted string from the passed value.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$value` |  |


**Returns** `string`

### getUsernameAttribute

```php
public function getUsernameAttribute()
```

### hasSingleSignOnPermission

```php
public function hasSingleSignOnPermission()
```

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

**Returns** `bool`

### isAllowedToAuthenticate

```php
public function isAllowedToAuthenticate()
```

Should the user be allowed to authenticate

**Returns** `bool`

### isEmailAddressVerified

```php
public function isEmailAddressVerified()
```

Returns if the clients' owners email address is verified.

**Returns** `bool`

### updateLastLogin

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

### customFieldValues

```php
public function customFieldValues()
```

**Returns** `HasMany\|CustomFieldValue`

### hasPermission

```php
public function hasPermission($permission)
```

This fulfills the UserInterface

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string|int` | `$permission` |  |


**Returns** `bool`

### tickets

```php
public function tickets()
```

A client can have many tickets.

**Returns** `HasMany`

### isOptedInToMarketingEmails

```php
public function isOptedInToMarketingEmails()
```

Determine if user is opted in to marketing emails.

**Returns** `bool`

### marketingEmailOptIn

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

Opt in to email marketing.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$userIp` |  |
| `bool` | `$performCurrentSettingCheck` |  |


**Returns** `self`

### marketingEmailOptOut

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

Opt out of email marketing.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$userIp` |  |
| `bool` | `$performCurrentSettingCheck` |  |


**Returns** `self`

### logActivity

```php
public function logActivity($message)
```

Log activity.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$message` |  |


**Returns** `self`

### closeClient

```php
public function closeClient(): void
```

Closes a Client Account and cancels associated data.

### deleteEntireClient

```php
public function deleteEntireClient(): ?bool
```

Deletes a client and all associated data.

**Returns** `bool\|null`

### getGroups

```php
public static function getGroups()
```

### needsCardDetailsMigrated

```php
public function needsCardDetailsMigrated()
```

### needsBankDetailsMigrated

```php
public function needsBankDetailsMigrated()
```

### needsUnknownPaymentTokenMigrated

```php
public function needsUnknownPaymentTokenMigrated()
```

### needsAnyPaymentDetailsMigrated

```php
public function needsAnyPaymentDetailsMigrated()
```

### migratePaymentDetailsIfRequired

```php
public function migratePaymentDetailsIfRequired($forceInCron = false)
```

### markCardDetailsAsMigrated

```php
public function markCardDetailsAsMigrated()
```

### markBankDetailsAsMigrated

```php
public function markBankDetailsAsMigrated()
```

### markPaymentTokenMigrated

```php
public function markPaymentTokenMigrated()
```

### payMethods

```php
public function payMethods()
```

**Returns** `HasMany`

### defaultBillingContact

```php
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

```php
public function getGroupNameAttribute()
```

**Returns** `string`

### domainSslStatuses

```php
public function domainSslStatuses()
```

**Returns** `HasMany`

### generateUniquePlaceholderEmail

```php
public function generateUniquePlaceholderEmail()
```

### deleteAllCreditCards

```php
public function deleteAllCreditCards()
```

### getUsedCardTypes

```php
public static function getUsedCardTypes()
```

Get the card types currently used.

**Returns** `array`

### buildBillingContactsArray

```php
public function buildBillingContactsArray()
```

**Returns** `array`

### createRemoteCardPayMethod

```php
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`

### createCardPayMethod

```php
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`

### createBankPayMethod

```php
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`

### createRemoteBankPayMethod

```php
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`

### getClientDiscountPercentage

```php
public function getClientDiscountPercentage()
```

Get client discount percentage.

**Returns** `float`

### addCredit

```php
public function addCredit($description, $amount)
```

Add a credit + credit log entry.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$description` |  |
| `float` | `$amount` |  |


**Returns** `self`

### getLink

```php
public function getLink()
```

### authedUserIsOwner

```php
public function authedUserIsOwner()
```

### getAuthUserById

```php
public function getAuthUserById($userId)
```

### getCurrencyCodeAttribute

```php
public function getCurrencyCodeAttribute(): string
```

### mergeTo

```php
public function mergeTo(Client $client): self
```

### deleteUsersWithNoOtherClientAccounts

```php
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

```php
public function deleteTransactions(): void
```

Delete all transactions belonging to this account

### disassociateTransactions

```php
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

```php
public function getDisplayNameFormattedAttribute(): string
```

### subscriptions

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