private function buildUniqueRules() {

		$rulescopes = $this->rules;

		foreach($rulescopes as $scope => &$rules){

	        foreach ($rules as $field => &$ruleset) {
	            // If $ruleset is a pipe-separated string, switch it to array
	            $ruleset = (is_string($ruleset))? explode('|', $ruleset) : $ruleset;

	            foreach ($ruleset as &$rule) {
					if (str_contains($rule, 'unique') && str_contains($rule, '{id}') == false) {
						$params = explode(',', $rule);

						$uniqueRules = array();

						// Append table name if needed
						$table = explode(':', $params[0]);
						if (count($table) == 1)
							$uniqueRules[1] = $this->table;
						else
							$uniqueRules[1] = $table[1];

						// Append field name if needed
						if (count($params) == 1)
							$uniqueRules[2] = $field;
						else
							$uniqueRules[2] = $params[1];

						$uniqueRules[3] = $this->getKey();
				        $uniqueRules[4] = $this->getKeyName();

						$rule = 'unique:' . implode(',', $uniqueRules);
					}elseif(str_contains($rule, 'unique') && str_contains($rule, '{id}')){  
						$rule = str_replace('{id}', $this->getKey(), $rule);
					} // end if str_contains
	              
	            } // end foreach ruleset
	        }

    	}
        
        $this->rules = $rulescopes;
    }