# WHMCS\CustomField

`Class` · extends `AbstractModel`

Custom Fields model class

## Constants

| Name | Description |
|  --- | --- |
| `TYPE_ADDON` |  |
| `TYPE_CLIENT` |  |
| `TYPE_PRODUCT` |  |
| `TYPE_SUPPORT` |  |


## Methods

### boot

```php
public static function boot()
```

### scopeClientFields

```php
public function scopeClientFields(Builder $query)
```

Obtain all the client custom fields

**Parameters**

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


**Returns** `Builder`

### scopeProductFields

```php
public function scopeProductFields(Builder $query, $productId)
```

Obtain all the product custom fields for a specific product.

**Parameters**

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


**Returns** `Builder`

### scopeSupportFields

```php
public function scopeSupportFields(Builder $query, $departmentId)
```

Obtain all the support custom fields for a specific support department.

**Parameters**

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


**Returns** `Builder`

### scopeAddonFields

```php
public function scopeAddonFields(Builder $query, $addonId)
```

Obtain all the addon custom fields for a specific addon id.

**Parameters**

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


**Returns** `Builder`

### product

```php
public function product()
```

A custom field can belong to a single product

**Returns** `HasOne\|Product`

### addon

```php
public function addon()
```

A custom field can belong to a single product addon.

**Returns** `HasOne\|Addon`

### getFieldNameAttribute

```php
public function getFieldNameAttribute($fieldName)
```

Get the custom field's name - this will override the output from the db value if set in Lang.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$fieldName` | The value from the database |


**Returns** `string`

### getDescriptionAttribute

```php
public function getDescriptionAttribute($description)
```

Get the custom field's name - this will override the output from the db value if set in Lang.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$description` | The value from the database |


**Returns** `string`

### customFieldValues

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

**Returns** `HasMany\|CustomFieldValue`

### getFieldName

```php
public static function getFieldName($fieldId, $fallback = '', $language = null)
```

Obtain the custom field name for the current language, passed language or fallback to the currently
defined value for the product group.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `int` | `$fieldId` |  |
| `string` | `$fallback` |  |
| `string` | `$language` |  |


**Returns** `string`

### getFriendlyDisplayFieldName

```php
public function getFriendlyDisplayFieldName(): ?string
```

Attempt to retrieve an alternate field name that is embedded within this object’s fieldName

**Returns** `string\|null`

### hasFriendlyDisplayFieldName

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

Determines if an alternate field name is embedded within this object’s fieldName,
if dynamic translations are enabled

**Returns** `bool`

### getFieldNameTranslation

```php
public function getFieldNameTranslation(?string $language, bool $assumeEnabled = false): ?string
```

Attempt to retrieve a dynamic translation of this object's fieldName

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `null|string` | `$language` |  |
| `bool` | `$assumeEnabled` | Attempt translation despite dynamic translations possibly being disabled |


**Returns** `null\|string`

### getDescription

```php
public static function getDescription($fieldId, $fallback = '', $language = null)
```

Obtain the custom field description for the current language, passed language or fallback to the currently
defined value for the product group.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `int` | `$fieldId` |  |
| `string` | `$fallback` |  |
| `string` | `$language` |  |


**Returns** `string`

### scopeRequired

```php
public function scopeRequired(Builder $query): Builder
```

### scopeOnOrderShow

```php
public function scopeOnOrderShow(Builder $query): Builder
```

### scopeOnOrderHide

```php
public function scopeOnOrderHide(Builder $query): Builder
```

### scopeAdminOnly

```php
public function scopeAdminOnly(Builder $query): Builder
```

### scopeNotAdminOnly

```php
public function scopeNotAdminOnly(Builder $query): Builder
```

### scopeShowOnOrderForm

```php
public function scopeShowOnOrderForm(Builder $query): Builder
```

### commonQueryBuilder

```php
public static function commonQueryBuilder($type, $relid = 0, bool $onOrderOnly = false)
```

Initialize a query for custom fields that outlines common requirements and default behaviors.

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$type` | Type of custom field |
| `int` | `$relid` | Optionally limit fields to those associated with the $type's ID. |
| `bool` | `$onOrderOnly` | true=include on fields with "show on order" or "required" enabled. A "required" field is assumed to also be present in any context "show on order" enabled fields are. false=no additional criteria related to "show on order" or "required". |


**Returns** `Builder`

### getType

```php
public function getType(): ?string
```

### getOptions

```php
public function getOptions(): array
```