protected function injectUniqueIdentifierToRules(array $rules)
    {
        foreach ($rules as $field => &$ruleset) {
            // If the ruleset is a pipe-delimited string, convert it to an array.
            $ruleset = is_string($ruleset) ? explode('|', $ruleset) : $ruleset;

            foreach ($ruleset as &$rule) {
            	// Only treat stringy definitions and leave Rule classes and Closures as-is.
            	if (is_string($rule)) {
            		$parameters = explode(':', $rule);
	                $validationRule = array_shift($parameters);

	                if ($method = $this->getUniqueIdentifierInjectorMethod($validationRule)) {
	                    $rule = call_user_func_array(
	                        [$this, $method],
	                        [explode(',', head($parameters)), $field]
	                    );
	                }
            	}
            }
        }

        return $rules;
    }
protected function injectUniqueIdentifierToRules(array $rules)
    {
        foreach ($rules as $field => &$ruleset) {
            // If the ruleset is a pipe-delimited string, convert it to an array.
            $ruleset = is_string($ruleset) ? explode('|', $ruleset) : $ruleset;

            foreach ($ruleset as &$rule) {
            	// Only treat stringy definitions and leave Rule classes and Closures as-is.
            	if (is_string($rule)) {
            		$parameters = explode(':', $rule);
	                $validationRule = array_shift($parameters);

	                if ($method = $this->getUniqueIdentifierInjectorMethod($validationRule)) {
	                    $rule = call_user_func_array(
	                        [$this, $method],
	                        [explode(',', head($parameters)), $field]
	                    );
	                }
            	}
            }
        }

        return $rules;
    }
protected function injectUniqueIdentifierToRules ( array $ rules ) { foreach ( $ rules as $ field => & $ ruleset ) { // If the ruleset is a pipe-delimited string, convert it to an array. $ ruleset = is_string ( $ ruleset ) ? explode ( '|' , $ ruleset ) : $ ruleset ; foreach ( $ ruleset as & $ rule ) { // Only treat stringy definitions and leave Rule classes and Closures as-is. if ( is_string ( $ rule ) ) { $ parameters = explode ( ':' , $ rule ) ; $ validationRule = array_shift ( $ parameters ) ; if ( $ method = $ this -> getUniqueIdentifierInjectorMethod ( $ validationRule ) ) { $ rule = call_user_func_array ( [ $ this , $ method ] , [ explode ( ',' , head ( $ parameters ) ) , $ field ] ) ; } } } } return $ 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.

@param  array $rules
@return array
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 .