protected function addUniqueRuleException(array $rules, $id)
	{

		// update all unique rules
		foreach ($rules as $key => &$rule)
		{
			if(is_array($rule))
			{
				$rule = $this->addUniqueRuleException($rule, $id);
				continue;
			}
			// check for unique rule
			$unique_pos = strpos($rule, 'unique:');
			// if rule has unique restriction
			if($unique_pos !== false)
			{

				// find if there is other rules after unique rule
				// if there are put cursor between these rules, 
				// otherwise put it on the end of string
				$next_rule_pos = strpos($rule, '|', $unique_pos);
				if($next_rule_pos !== false)
				{
					$insert_pos = $next_rule_pos;
				}
				else
				{
					$insert_pos = strlen($rule);
				}

				// add exception for this id
				$rule = substr_replace($rule, ',' . $id . ',id', $insert_pos, 0);
			}
		}

		return $rules;

	}
protected function addUniqueRuleException(array $rules, $id)
	{

		// update all unique rules
		foreach ($rules as $key => &$rule)
		{
			if(is_array($rule))
			{
				$rule = $this->addUniqueRuleException($rule, $id);
				continue;
			}
			// check for unique rule
			$unique_pos = strpos($rule, 'unique:');
			// if rule has unique restriction
			if($unique_pos !== false)
			{

				// find if there is other rules after unique rule
				// if there are put cursor between these rules, 
				// otherwise put it on the end of string
				$next_rule_pos = strpos($rule, '|', $unique_pos);
				if($next_rule_pos !== false)
				{
					$insert_pos = $next_rule_pos;
				}
				else
				{
					$insert_pos = strlen($rule);
				}

				// add exception for this id
				$rule = substr_replace($rule, ',' . $id . ',id', $insert_pos, 0);
			}
		}

		return $rules;

	}
protected function addUniqueRuleException ( array $ rules , $ id ) { // update all unique rules foreach ( $ rules as $ key => & $ rule ) { if ( is_array ( $ rule ) ) { $ rule = $ this -> addUniqueRuleException ( $ rule , $ id ) ; continue ; } // check for unique rule $ unique_pos = strpos ( $ rule , 'unique:' ) ; // if rule has unique restriction if ( $ unique_pos !== false ) { // find if there is other rules after unique rule // if there are put cursor between these rules,  // otherwise put it on the end of string $ next_rule_pos = strpos ( $ rule , '|' , $ unique_pos ) ; if ( $ next_rule_pos !== false ) { $ insert_pos = $ next_rule_pos ; } else { $ insert_pos = strlen ( $ rule ) ; } // add exception for this id $ rule = substr_replace ( $ rule , ',' . $ id . ',id' , $ insert_pos , 0 ) ; } } return $ rules ; }
Add exception to any unique rules for given object id

@param array $params
@param array $rules

@return array
Add exception to any unique rules for given object id