MailTemplate
extends Model
in package
Uses
Validation
System\Models\MailTemplate
Tags
Table of Contents
- $belongsTo : mixed
- $code : string|null
- $content_html : string|null
- $content_text : string|null
- $created_at : Carbon|null
- $description : string|null
- $id : int
- $is_custom : int
- $layout_id : int|null
- $rules : array<string|int, mixed>
- $subject : string|null
- $updated_at : Carbon|null
- $fillable : array<string|int, mixed>
- $guarded : array<string|int, mixed>
- $table : string
- $validationDefaultAttrNames : array<string|int, mixed>
- $validationErrors : MessageBag
- afterFetch() : mixed
- all() :
- allTemplates() : array<string|int, mixed>
- Returns a list of all mail templates.
- bootValidation() : void
- Boot the validation trait for this model.
- errors() : MessageBag
- Get validation error message collection for the Model
- fillFromContent() : mixed
- fillFromView() : mixed
- findOrMakeTemplate() : mixed
- forceSave() : bool
- Force save the model even if validation fails.
- get() :
- isAttributeRequired() : bool
- Determines if an attribute is required based on the validation rules.
- listAllTemplates() : array<string|int, mixed>
- Returns an array of template codes and descriptions.
- newModelQuery() :
- newQuery() :
- query() :
- registerCallback() : mixed
- 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.
- syncAll() : void
- Syncronise all file templates to the database.
- 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().
- whereCode() :
- whereContentHtml() :
- whereContentText() :
- whereCreatedAt() :
- whereDescription() :
- whereId() :
- whereIsCustom() :
- whereLayoutId() :
- whereSubject() :
- whereUpdatedAt() :
- fillFromSections() : mixed
- getRelationValidationValue() : mixed
- Attachments validate differently to their simple values.
- getTemplateSections() : mixed
- 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
Properties
$belongsTo
public
mixed
$belongsTo
= ['layout' => SystemModelsMailLayout::class]
$code
public
string|null
$code
$content_html
public
string|null
$content_html
$content_text
public
string|null
$content_text
$created_at
public
Carbon|null
$created_at
$description
public
string|null
$description
$id
public
int
$id
$is_custom
public
int
$is_custom
$layout_id
public
int|null
$layout_id
$rules
public
array<string|int, mixed>
$rules
= ['code' => 'required|unique:system_mail_templates', 'subject' => 'required', 'description' => 'required', 'content_html' => 'required']
Validation rules
$subject
public
string|null
$subject
$updated_at
public
Carbon|null
$updated_at
$fillable
protected
array<string|int, mixed>
$fillable
= []
Fillable fields
$guarded
protected
array<string|int, mixed>
$guarded
= []
Guarded fields
$table
protected
string
$table
= 'system_mail_templates'
The database table used by the model.
$validationDefaultAttrNames
protected
array<string|int, mixed>
$validationDefaultAttrNames
= []
Default custom attribute names.
$validationErrors
protected
MessageBag
$validationErrors
The message bag instance containing validation error messages
Methods
afterFetch()
public
afterFetch() : mixed
Return values
mixed —all()
public
static all(mixed $columns) :
Parameters
- $columns : mixed
Return values
—allTemplates()
Returns a list of all mail templates.
public
static allTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array of the MailTemplate objects.
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 —fillFromContent()
public
fillFromContent(mixed $content) : mixed
Parameters
- $content : mixed
Return values
mixed —fillFromView()
public
fillFromView(mixed $path) : mixed
Parameters
- $path : mixed
Return values
mixed —findOrMakeTemplate()
public
static findOrMakeTemplate(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —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
—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 —listAllTemplates()
Returns an array of template codes and descriptions.
public
static listAllTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed> —newModelQuery()
public
static newModelQuery() :
Return values
—newQuery()
public
static newQuery() :
Return values
—query()
public
static query() :
Return values
—registerCallback()
public
static registerCallback(callable $callback) : mixed
Parameters
- $callback : callable
Tags
Return values
mixed —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 —syncAll()
Syncronise all file templates to the database.
public
static syncAll() : void
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 —whereCode()
public
static whereCode(mixed $value) :
Parameters
- $value : mixed
Return values
—whereContentHtml()
public
static whereContentHtml(mixed $value) :
Parameters
- $value : mixed
Return values
—whereContentText()
public
static whereContentText(mixed $value) :
Parameters
- $value : mixed
Return values
—whereCreatedAt()
public
static whereCreatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereDescription()
public
static whereDescription(mixed $value) :
Parameters
- $value : mixed
Return values
—whereId()
public
static whereId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereIsCustom()
public
static whereIsCustom(mixed $value) :
Parameters
- $value : mixed
Return values
—whereLayoutId()
public
static whereLayoutId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereSubject()
public
static whereSubject(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUpdatedAt()
public
static whereUpdatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—fillFromSections()
protected
fillFromSections(mixed $sections) : mixed
Parameters
- $sections : mixed
Return values
mixed —getRelationValidationValue()
Attachments validate differently to their simple values.
protected
getRelationValidationValue(mixed $relationName) : mixed
Parameters
- $relationName : mixed
Return values
mixed —getTemplateSections()
protected
static getTemplateSections(mixed $code) : mixed
Parameters
- $code : 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