Preference
extends Model
in package
Uses
Validation
Backend\Models\Preference
Tags
Table of Contents
- DEFAULT_THEME = 'twilight'
- $group : string
- $id : int
- $implement : array<string|int, mixed>
- $item : string
- $namespace : string
- $rules : array<string|int, mixed>
- $settingsCode : string
- $settingsFields : mixed
- $user_id : int
- $value : string|null
- $validationDefaultAttrNames : array<string|int, mixed>
- $validationErrors : MessageBag
- afterSave() : mixed
- all() :
- applyConfigValues() : void
- Overrides the config with the user's preference.
- beforeValidate() : mixed
- bootValidation() : void
- Boot the validation trait for this model.
- errors() : MessageBag
- Get validation error message collection for the Model
- forceSave() : bool
- Force save the model even if validation fails.
- get() :
- getEditorThemeOptions() : array<string|int, mixed>
- Returns the theme options for the backend editor.
- getLocaleOptions() : array<string|int, mixed>
- Returns available options for the "locale" attribute.
- getTimezoneOptions() : array<string|int, mixed>
- Returns all available timezone options.
- initSettingsData() : void
- Initialize the seed data for this model. This only executes when the model is first created or reset to default.
- isAttributeRequired() : bool
- Determines if an attribute is required based on the validation rules.
- newModelQuery() :
- newQuery() :
- query() :
- resetDefault() : void
- Called when this model is reset to default by the user.
- setAppFallbackLocale() : void
- Same as setAppLocale except for the fallback definition.
- setAppLocale() : void
- Set the application's locale based on the user preference.
- setValidationAttributeName() : void
- Programatically sets the validation attribute names, will take lower priority to model defined attribute names found in `$attributeNames`.
- setValidationAttributeNames() : void
- Programatically sets multiple validation attribute names.
- validate() : bool
- Validate the model instance
- validated() : void
- Create a new native event for handling afterValidate().
- validating() : void
- Create a new native event for handling beforeValidate().
- whereGroup() :
- whereId() :
- whereItem() :
- whereNamespace() :
- whereUserId() :
- whereValue() :
- getFallbackLocale() : string
- Attempt to extract the language from the locale, otherwise use the configuration.
- getRelationValidationValue() : mixed
- Attachments validate differently to their simple values.
- getValidationAttributes() : array<string|int, mixed>
- Returns the model data used for validation.
- makeValidator() : Validator
- Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.
- processRuleFieldNames() : array<string|int, mixed>
- Processes field names in a rule array.
- processValidationRules() : mixed
- Process rules
- processValidationUniqueRule() : string
- Rebuilds the unique validation rule to force for the existing ID
Constants
DEFAULT_THEME
public
mixed
DEFAULT_THEME
= 'twilight'
Properties
$group
public
string
$group
$id
public
int
$id
$implement
public
array<string|int, mixed>
$implement
= [BackendBehaviorsUserPreferencesModel::class]
Behaviors implemented by this model.
$item
public
string
$item
$namespace
public
string
$namespace
$rules
public
array<string|int, mixed>
$rules
= []
Validation rules
$settingsCode
public
string
$settingsCode
= 'backend::backend.preferences'
Unique code
$settingsFields
public
mixed
$settingsFields
= 'fields.yaml'
Settings form field defitions
$user_id
public
int
$user_id
$value
public
string|null
$value
$validationDefaultAttrNames
protected
array<string|int, mixed>
$validationDefaultAttrNames
= []
Default custom attribute names.
$validationErrors
protected
MessageBag
$validationErrors
The message bag instance containing validation error messages
Methods
afterSave()
public
afterSave() : mixed
Return values
mixed —all()
public
static all(mixed $columns) :
Parameters
- $columns : mixed
Return values
—applyConfigValues()
Overrides the config with the user's preference.
public
static applyConfigValues() : void
Return values
void —beforeValidate()
public
beforeValidate() : mixed
Return values
mixed —bootValidation()
Boot the validation trait for this model.
public
static bootValidation() : void
Return values
void —errors()
Get validation error message collection for the Model
public
errors() : MessageBag
Return values
MessageBag —forceSave()
Force save the model even if validation fails.
public
forceSave([mixed $options = null ][, mixed $sessionKey = null ]) : bool
Parameters
- $options : mixed = null
- $sessionKey : mixed = null
Return values
bool —get()
public
static get(mixed $columns) :
Parameters
- $columns : mixed
Return values
—getEditorThemeOptions()
Returns the theme options for the backend editor.
public
getEditorThemeOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getLocaleOptions()
Returns available options for the "locale" attribute.
public
getLocaleOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getTimezoneOptions()
Returns all available timezone options.
public
getTimezoneOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —initSettingsData()
Initialize the seed data for this model. This only executes when the model is first created or reset to default.
public
initSettingsData() : void
Return values
void —isAttributeRequired()
Determines if an attribute is required based on the validation rules.
public
isAttributeRequired(string $attribute[, bool $checkDependencies = true ]) : bool
Parameters
- $attribute : string
- $checkDependencies : bool = true
-
Checks the attribute dependencies (for required_if & required_with rules). Note that it will only be checked up to the next level, if another dependent rule is found then it will just assume the field is required
Return values
bool —newModelQuery()
public
static newModelQuery() :
Return values
—newQuery()
public
static newQuery() :
Return values
—query()
public
static query() :
Return values
—resetDefault()
Called when this model is reset to default by the user.
public
resetDefault() : void
Return values
void —setAppFallbackLocale()
Same as setAppLocale except for the fallback definition.
public
static setAppFallbackLocale() : void
Return values
void —setAppLocale()
Set the application's locale based on the user preference.
public
static setAppLocale() : void
Return values
void —setValidationAttributeName()
Programatically sets the validation attribute names, will take lower priority to model defined attribute names found in `$attributeNames`.
public
setValidationAttributeName(string $attr, string $name) : void
Parameters
- $attr : string
- $name : string
Return values
void —setValidationAttributeNames()
Programatically sets multiple validation attribute names.
public
setValidationAttributeNames(array<string|int, mixed> $attributeNames) : void
Parameters
- $attributeNames : array<string|int, mixed>
Return values
void —validate()
Validate the model instance
public
validate([mixed $rules = null ][, mixed $customMessages = null ][, mixed $attributeNames = null ]) : bool
Parameters
- $rules : mixed = null
- $customMessages : mixed = null
- $attributeNames : mixed = null
Return values
bool —validated()
Create a new native event for handling afterValidate().
public
static validated(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —validating()
Create a new native event for handling beforeValidate().
public
static validating(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —whereGroup()
public
static whereGroup(mixed $value) :
Parameters
- $value : mixed
Return values
—whereId()
public
static whereId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereItem()
public
static whereItem(mixed $value) :
Parameters
- $value : mixed
Return values
—whereNamespace()
public
static whereNamespace(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUserId()
public
static whereUserId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereValue()
public
static whereValue(mixed $value) :
Parameters
- $value : mixed
Return values
—getFallbackLocale()
Attempt to extract the language from the locale, otherwise use the configuration.
protected
getFallbackLocale(mixed $locale) : string
Parameters
- $locale : mixed
Return values
string —getRelationValidationValue()
Attachments validate differently to their simple values.
protected
getRelationValidationValue(mixed $relationName) : mixed
Parameters
- $relationName : mixed
Return values
mixed —getValidationAttributes()
Returns the model data used for validation.
protected
getValidationAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —makeValidator()
Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.
protected
static makeValidator(mixed $data, mixed $rules, mixed $customMessages, mixed $attributeNames[, mixed $connection = null ]) : Validator
Parameters
- $data : mixed
- $rules : mixed
- $customMessages : mixed
- $attributeNames : mixed
- $connection : mixed = null
Return values
Validator —processRuleFieldNames()
Processes field names in a rule array.
protected
processRuleFieldNames(array<string|int, mixed> $rules) : array<string|int, mixed>
Converts any field names using array notation (ie. field[child]) into dot notation (ie. field.child)
Parameters
- $rules : array<string|int, mixed>
-
Rules array
Return values
array<string|int, mixed> —processValidationRules()
Process rules
protected
processValidationRules(mixed $rules) : mixed
Parameters
- $rules : mixed
Return values
mixed —processValidationUniqueRule()
Rebuilds the unique validation rule to force for the existing ID
protected
processValidationUniqueRule(string $definition, string $fieldName) : string
Parameters
- $definition : string
- $fieldName : string