Custom Fields model class

class CustomField extends AbstractModel

Constants

TYPE_ADDON

TYPE_CLIENT

TYPE_PRODUCT

TYPE_SUPPORT

Properties summary

Type Property Description
protected $table
protected $columnMap
protected $commaSeparated
protected $fillable Define the fields that can be hydrated by a firstOrNew call.
int $id A custom fields unique identifier
string $type The type of custom field client|product|support|addon
int $relatedId The related id of the custom field type
string $fieldName The name of the custom field
string $fieldType The type of the custom field dropdown|link|text|textarea|tickbox|password
string $description The description of the custom field
string[] $fieldOptions The options available for the dropdown type
string $regularExpression The Regular Expression Validation String
string $adminOnly Is the field only visible for Admins
string $required Is the field required
string $showOnOrderForm Should the field show in the orderForm
string $showOnInvoice Should the field show on the invoice
int $sortOrder The order the field should be displayed
Carbon $createdAt The date a custom field was created.
Carbon $updatedAt The date a custom field was last modified.
Collection|Product $product The product a custom field belongs to
Collection|Addon $addon The product addon a custom field belongs to
Collection|CustomFieldValue $customFieldValues The custom field values for this custom field

Methods summary

Return Type Method Name Description
static  boot() -
Builder scopeClientFields(Builder $query) Obtain all the client custom fields
Builder scopeProductFields(Builder $query, int $productId) Obtain all the product custom fields for a specific product.
Builder scopeSupportFields(Builder $query, int $departmentId) Obtain all the support custom fields for a specific support department.
Builder scopeAddonFields(Builder $query, int $addonId) Obtain all the addon custom fields for a specific addon id.
HasOne|Product product() A custom field can belong to a single product
HasOne|Addon addon() A custom field can belong to a single product addon.
string getFieldNameAttribute(string $fieldName) Get the custom field's name - this will override the output from the db value if set in Lang.
string getDescriptionAttribute(string $description) Get the custom field's name - this will override the output from the db value if set in Lang.
HasMany|CustomFieldValue customFieldValues() -
static string getFieldName(int $fieldId, string $fallback = '', string $language = null) Obtain the custom field name for the current language, passed language or fallback to the currently defined value for the product group.
string|null getFriendlyDisplayFieldName() Attempt to retrieve an alternate field name that is embedded within this object’s fieldName
bool hasFriendlyDisplayFieldName() Determines if an alternate field name is embedded within this object’s fieldName, if dynamic translations are enabled
string|null getFieldNameTranslation(string|null $language, bool $assumeEnabled = false) Attempt to retrieve a dynamic translation of this object's fieldName
static string getDescription(int $fieldId, string $fallback = '', string $language = null) Obtain the custom field description for the current language, passed language or fallback to the currently defined value for the product group.
Builder scopeRequired(Builder $query) -
Builder scopeOnOrderShow(Builder $query) -
Builder scopeOnOrderHide(Builder $query) -
static Builder commonQueryBuilder(string $type, int $relid, bool $onOrderOnly = false) Initialize a query for custom fields that outlines common requirements and default behaviors.

Details

static boot ()

Builder scopeClientFields (Builder $query)

Obtain all the client custom fields

Parameters

Builder $query

Return Value

Builder

Builder scopeProductFields (Builder $query, int $productId)

Obtain all the product custom fields for a specific product.

Parameters

Builder $query
int $productId

Return Value

Builder

Builder scopeSupportFields (Builder $query, int $departmentId)

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

Parameters

Builder $query
int $departmentId

Return Value

Builder

Builder scopeAddonFields (Builder $query, int $addonId)

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

Parameters

Builder $query
int $addonId

Return Value

Builder

HasOne|Product product ()

A custom field can belong to a single product

Return Value

HasOne|Product

HasOne|Addon addon ()

A custom field can belong to a single product addon.

Return Value

HasOne|Addon

string getFieldNameAttribute (string $fieldName)

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

Parameters

string $fieldName The value from the database

Return Value

string

string getDescriptionAttribute (string $description)

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

Parameters

string $description The value from the database

Return Value

string

HasMany|CustomFieldValue customFieldValues ()

Return Value

HasMany|CustomFieldValue

static string getFieldName (int $fieldId, string $fallback = '', string $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

int $fieldId
string $fallback
string $language

Return Value

string

string|null getFriendlyDisplayFieldName ()

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

Return Value

string|null

bool hasFriendlyDisplayFieldName ()

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

Return Value

bool

string|null getFieldNameTranslation (string|null $language, bool $assumeEnabled = false)

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

Parameters

string|null $language
bool $assumeEnabled Attempt translation despite dynamic translations possibly being disabled

Return Value

string|null

static string getDescription (int $fieldId, string $fallback = '', string $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

int $fieldId
string $fallback
string $language

Return Value

string

Builder scopeRequired (Builder $query)

Parameters

Builder $query

Return Value

Builder

Builder scopeOnOrderShow (Builder $query)

Parameters

Builder $query

Return Value

Builder

Builder scopeOnOrderHide (Builder $query)

Parameters

Builder $query

Return Value

Builder

static Builder commonQueryBuilder (string $type, int $relid, bool $onOrderOnly = false)

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

Parameters

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".

Return Value

Builder