trait RuleInjector

Methods

bool
getInjectRuleParameters()

Returns whether or not the model will add it's unique identifier to the rules when validating.

void
setInjectRuleParameters(bool $value)

Set the model to add unique identifier to rules when performing validation.

array
injectParametersToRules(array $rules)

If the model already exists and it has unique validations it is going to fail validation unless we also pass it's primary key to the rule so that it may be ignored.

mixed
getRuleInjectorMethod(string $validationRule)

Get the dynamic method name for a unique identifier or custom injector rule if it exists, otherwise return false.

string
prepareUniqueRule(array $parameters, string $field)

Prepare a rule, adding the table name, column and model identifier if required.

string
prepareUniqueWithRule(array $parameters, string $field)

Prepare a unique_with rule, adding the model identifier if required.

Details

at line 15
bool getInjectRuleParameters()

Returns whether or not the model will add it's unique identifier to the rules when validating.

Return Value

bool

at line 27
void setInjectRuleParameters(bool $value)

Set the model to add unique identifier to rules when performing validation.

Parameters

bool $value

Return Value

void

at line 44
protected array injectParametersToRules(array $rules)

If the model already exists and it has unique validations it is going to fail validation unless we also pass it's primary key to the rule so that it may be ignored.

This will go through all the rules and append the model's primary key to the unique rules so that the validation will work as expected.

Parameters

array $rules

Return Value

array

at line 76
protected mixed getRuleInjectorMethod(string $validationRule)

Get the dynamic method name for a unique identifier or custom injector rule if it exists, otherwise return false.

Parameters

string $validationRule

Return Value

mixed

at line 91
protected string prepareUniqueRule(array $parameters, string $field)

Prepare a rule, adding the table name, column and model identifier if required.

Parameters

array $parameters
string $field

Return Value

string

at line 140
protected string prepareUniqueWithRule(array $parameters, string $field)

Prepare a unique_with rule, adding the model identifier if required.

Parameters

array $parameters
string $field

Return Value

string