Custom Fields model class

class CustomField extends AbstractModel

Properties summary

Type Property Description
protected $table
protected $columnMap
protected $commaSeparated
int $id A custom fields unique identifier
string $type The type of custom field client|product|support
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 $showOrder Should the field show in the orderForm
string $showInvoice 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

Methods summary

Return Type Method Name Description
static  boot() -
Builder|CustomField scopeClientFields(Builder $query) Obtain all the client custom fields
Builder|CustomField scopeProductFields(Builder $query, int $productId) Obtain all the product custom fields for a specific product.
Builder|CustomField scopeSupportFields(Builder $query, int $departmentId) Obtain all the support custom fields for a specific support department.
HasOne|Product product() A custom field can belong to a single product
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.
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.
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.

Details

static boot ()

Builder|CustomField scopeClientFields (Builder $query)

Obtain all the client custom fields

Parameters

Builder $query

Return Value

Builder|CustomField

Builder|CustomField scopeProductFields (Builder $query, int $productId)

Obtain all the product custom fields for a specific product.

Parameters

Builder $query
int $productId

Return Value

Builder|CustomField

Builder|CustomField scopeSupportFields (Builder $query, int $departmentId)

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

Parameters

Builder $query
int $departmentId

Return Value

Builder|CustomField

HasOne|Product product ()

A custom field can belong to a single product

Return Value

HasOne|Product

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

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

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