public function generateExistRules($table, $columnBehaviors)
    {
        $rules = [];
        foreach ($table->foreignKeys as $refs) {
            $refClassName = $this->generateClassName($refs[0]);
            unset($refs[0]);
            $attributes = implode("', '", array_keys($refs));
            $targetAttributes = [];
            foreach ($refs as $key => $value) {
                if (isset($columnBehaviors[$key]) && $columnBehaviors[$key] !== false) {
                    continue 2;
                }
                $targetAttributes[] = "'$key' => '$value'";
            }
            $targetAttributes = implode(', ', $targetAttributes);
            $rules[] = "[['$attributes'], 'exist', 'skipOnError' => true, "
                . "'targetClass' => $refClassName::className(), 'targetAttribute' => [$targetAttributes]],";
        }
        return $rules;
    }
public function generateExistRules($table, $columnBehaviors)
    {
        $rules = [];
        foreach ($table->foreignKeys as $refs) {
            $refClassName = $this->generateClassName($refs[0]);
            unset($refs[0]);
            $attributes = implode("', '", array_keys($refs));
            $targetAttributes = [];
            foreach ($refs as $key => $value) {
                if (isset($columnBehaviors[$key]) && $columnBehaviors[$key] !== false) {
                    continue 2;
                }
                $targetAttributes[] = "'$key' => '$value'";
            }
            $targetAttributes = implode(', ', $targetAttributes);
            $rules[] = "[['$attributes'], 'exist', 'skipOnError' => true, "
                . "'targetClass' => $refClassName::className(), 'targetAttribute' => [$targetAttributes]],";
        }
        return $rules;
    }
public function generateExistRules ( $ table , $ columnBehaviors ) { $ rules = [ ] ; foreach ( $ table -> foreignKeys as $ refs ) { $ refClassName = $ this -> generateClassName ( $ refs [ 0 ] ) ; unset ( $ refs [ 0 ] ) ; $ attributes = implode ( "', '" , array_keys ( $ refs ) ) ; $ targetAttributes = [ ] ; foreach ( $ refs as $ key => $ value ) { if ( isset ( $ columnBehaviors [ $ key ] ) && $ columnBehaviors [ $ key ] !== false ) { continue 2 ; } $ targetAttributes [ ] = "'$key' => '$value'" ; } $ targetAttributes = implode ( ', ' , $ targetAttributes ) ; $ rules [ ] = "[['$attributes'], 'exist', 'skipOnError' => true, " . "'targetClass' => $refClassName::className(), 'targetAttribute' => [$targetAttributes]]," ; } return $ rules ; }
Generates exist rules for foreign key columns.
@param \yii\db\TableSchema $table the table schema
@param array $columnBehaviors
@return array the generated exist validation rules
Generates exist rules for foreign key columns .