public function getValidationRules()
    {
        $rules = parent::getValidationRules();

        foreach ($rules as &$rule) {
            if ($rule !== '_unique') {
                continue;
            }

            $model = $this->resolvePath();
            $table = $model->getTable();

            $rule = 'unique:'.$table.','.$this->getModelAttributeKey();
            if ($model->exists) {
                $rule .= ','.$model->getKey();
            }
        }
        unset($rule);

        return [$this->getPath() => $rules];
    }
public function getValidationRules()
    {
        $rules = parent::getValidationRules();

        foreach ($rules as &$rule) {
            if ($rule !== '_unique') {
                continue;
            }

            $model = $this->resolvePath();
            $table = $model->getTable();

            $rule = 'unique:'.$table.','.$this->getModelAttributeKey();
            if ($model->exists) {
                $rule .= ','.$model->getKey();
            }
        }
        unset($rule);

        return [$this->getPath() => $rules];
    }
public function getValidationRules ( ) { $ rules = parent :: getValidationRules ( ) ; foreach ( $ rules as & $ rule ) { if ( $ rule !== '_unique' ) { continue ; } $ model = $ this -> resolvePath ( ) ; $ table = $ model -> getTable ( ) ; $ rule = 'unique:' . $ table . ',' . $ this -> getModelAttributeKey ( ) ; if ( $ model -> exists ) { $ rule .= ',' . $ model -> getKey ( ) ; } } unset ( $ rule ) ; return [ $ this -> getPath ( ) => $ rules ] ; }
If FormElement has `_unique` rule, it will get all appropriate
validation rules based on underlying model.

@return array
If FormElement has _unique rule it will get all appropriate validation rules based on underlying model .