NotificationRule
extends Model
in package
Uses
Purgeable, Validation
RainLab\Notify\Models\NotificationRule
Tags
Table of Contents
- $class_name : string|null
- $code : string|null
- $condition_data : string|null
- $config_data : string|null
- $created_at : Carbon|null
- $description : string|null
- $hasMany : array<string|int, mixed>
- $id : int
- $is_custom : int
- $is_enabled : int
- $name : string|null
- $rules : array<string|int, mixed>
- $updated_at : Carbon|null
- $fillable : array<string|int, mixed>
- $guarded : array<string|int, mixed>
- $originalPurgeableValues : array<string|int, mixed>
- $purgeable : array<string|int, mixed>
- $table : string
- $validationDefaultAttrNames : array<string|int, mixed>
- $validationErrors : MessageBag
- addPurgeable() : $this
- Adds an attribute to the purgeable attributes list
- afterFetch() : mixed
- all() :
- applyClass() :
- applyEnabled() :
- applyEventClass() : bool
- Extends this class with the event class
- beforeValidate() : mixed
- bootPurgeable() : void
- Boot the purgeable trait for a model.
- bootValidation() : void
- Boot the validation trait for this model.
- createFromPreset() : mixed
- errors() : MessageBag
- Get validation error message collection for the Model
- forceSave() : bool
- Force save the model even if validation fails.
- get() :
- getEventClass() : mixed
- getEventObject() : NotificationEvent
- Returns the event class extension object.
- getExtraConditionRules() : array<string|int, mixed>
- Returns extra conditions provided by the event.
- getOriginalPurgeValue() : mixed
- Returns the original values of any purged attributes.
- getOriginalPurgeValues() : mixed
- Returns the original values of any purged attributes.
- getPurgeableAttributes() : mixed
- Returns a collection of fields that will be hashed.
- isAttributeRequired() : bool
- Determines if an attribute is required based on the validation rules.
- listRulesForEvent() : array<string|int, mixed>
- Returns an array of rule codes and descriptions.
- newModelQuery() :
- newQuery() :
- purgeAttributes() : array<string|int, mixed>
- Removes purged attributes from the dataset, used before saving.
- query() :
- restorePurgedValues() : mixed
- Restores the original values of any purged attributes.
- scopeApplyClass() : mixed
- scopeApplyEnabled() : 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-based presets to the database.
- triggerRule() : mixed
- Kicks off this notification rule, fires the event to obtain its parameters, checks the rule conditions evaluate as true, then spins over each action.
- 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().
- whereClassName() :
- whereCode() :
- whereConditionData() :
- whereConfigData() :
- whereCreatedAt() :
- whereDescription() :
- whereId() :
- whereIsCustom() :
- whereIsEnabled() :
- whereName() :
- whereUpdatedAt() :
- 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
Properties
$class_name
public
string|null
$class_name
$code
public
string|null
$code
$condition_data
public
string|null
$condition_data
$config_data
public
string|null
$config_data
$created_at
public
Carbon|null
$created_at
$description
public
string|null
$description
$hasMany
public
array<string|int, mixed>
$hasMany
= ['rule_conditions' => [RainLabNotifyModelsRuleCondition::class, 'key' => 'rule_host_id', 'conditions' => 'rule_parent_id is null', 'delete' => true], 'rule_actions' => [RainLabNotifyModelsRuleAction::class, 'key' => 'rule_host_id', 'delete' => true]]
Relations
$id
public
int
$id
$is_custom
public
int
$is_custom
$is_enabled
public
int
$is_enabled
$name
public
string|null
$name
$rules
public
array<string|int, mixed>
$rules
= ['name' => 'required']
The rules to be applied to the data.
$updated_at
public
Carbon|null
$updated_at
$fillable
protected
array<string|int, mixed>
$fillable
= []
Fillable fields
$guarded
protected
array<string|int, mixed>
$guarded
= ['config_data']
Guarded fields
$originalPurgeableValues
protected
array<string|int, mixed>
$originalPurgeableValues
= []
List of original attribute values before they were purged.
$purgeable
protected
array<string|int, mixed>
$purgeable
= ['event_name']
List of attribute names which should not be saved to the database.
$table
protected
string
$table
= 'rainlab_notify_notification_rules'
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
addPurgeable()
Adds an attribute to the purgeable attributes list
public
addPurgeable([array<string|int, mixed>|string|null $attributes = null ]) : $this
Parameters
- $attributes : array<string|int, mixed>|string|null = null
Return values
$this —afterFetch()
public
afterFetch() : mixed
Return values
mixed —all()
public
static all(mixed $columns) :
Parameters
- $columns : mixed
Return values
—applyClass()
public
static applyClass(mixed $class) :
Parameters
- $class : mixed
Return values
—applyEnabled()
public
static applyEnabled() :
Return values
—applyEventClass()
Extends this class with the event class
public
applyEventClass([string $class = null ]) : bool
Parameters
- $class : string = null
-
Class name
Return values
bool —beforeValidate()
public
beforeValidate() : mixed
Return values
mixed —bootPurgeable()
Boot the purgeable trait for a model.
public
static bootPurgeable() : void
Return values
void —bootValidation()
Boot the validation trait for this model.
public
static bootValidation() : void
Return values
void —createFromPreset()
public
static createFromPreset(mixed $code, mixed $preset) : mixed
Parameters
- $code : mixed
- $preset : mixed
Return values
mixed —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
—getEventClass()
public
getEventClass() : mixed
Return values
mixed —getEventObject()
Returns the event class extension object.
public
getEventObject() : NotificationEvent
Return values
NotificationEvent —getExtraConditionRules()
Returns extra conditions provided by the event.
public
getExtraConditionRules() : array<string|int, mixed>
Return values
array<string|int, mixed> —getOriginalPurgeValue()
Returns the original values of any purged attributes.
public
getOriginalPurgeValue(mixed $attribute) : mixed
Parameters
- $attribute : mixed
Return values
mixed —getOriginalPurgeValues()
Returns the original values of any purged attributes.
public
getOriginalPurgeValues() : mixed
Return values
mixed —getPurgeableAttributes()
Returns a collection of fields that will be hashed.
public
getPurgeableAttributes() : mixed
Return values
mixed —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 —listRulesForEvent()
Returns an array of rule codes and descriptions.
public
static listRulesForEvent(mixed $eventClass) : array<string|int, mixed>
Parameters
- $eventClass : mixed
Return values
array<string|int, mixed> —newModelQuery()
public
static newModelQuery() :
Return values
—newQuery()
public
static newQuery() :
Return values
—purgeAttributes()
Removes purged attributes from the dataset, used before saving.
public
purgeAttributes([mixed $attributesToPurge = null ]) : array<string|int, mixed>
Parameters
- $attributesToPurge : mixed = null
Return values
array<string|int, mixed> —Current attribute set
query()
public
static query() :
Return values
—restorePurgedValues()
Restores the original values of any purged attributes.
public
restorePurgedValues() : mixed
Return values
mixed —scopeApplyClass()
public
scopeApplyClass(mixed $query, mixed $class) : mixed
Parameters
- $query : mixed
- $class : mixed
Return values
mixed —scopeApplyEnabled()
public
scopeApplyEnabled(mixed $query) : mixed
Parameters
- $query : mixed
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-based presets to the database.
public
static syncAll() : void
Return values
void —triggerRule()
Kicks off this notification rule, fires the event to obtain its parameters, checks the rule conditions evaluate as true, then spins over each action.
public
triggerRule() : mixed
Return values
mixed —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 —whereClassName()
public
static whereClassName(mixed $value) :
Parameters
- $value : mixed
Return values
—whereCode()
public
static whereCode(mixed $value) :
Parameters
- $value : mixed
Return values
—whereConditionData()
public
static whereConditionData(mixed $value) :
Parameters
- $value : mixed
Return values
—whereConfigData()
public
static whereConfigData(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
—whereIsEnabled()
public
static whereIsEnabled(mixed $value) :
Parameters
- $value : mixed
Return values
—whereName()
public
static whereName(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUpdatedAt()
public
static whereUpdatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—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