示例#1
0
 /**
  * Validation rules
  * @return array
  */
 public function rules()
 {
     $rules = $this->_model->rules();
     $rules[] = ['tags', 'exist', 'targetClass' => Tag::className(), 'targetAttribute' => 'id', 'allowArray' => true];
     $rules['keyExists'] = ['key', 'unique', 'targetClass' => Post::className(), 'targetAttribute' => 'key', 'when' => function ($model) {
         return $model->key != $model->item->key;
     }];
     return $rules;
 }
示例#2
0
 public function getTags()
 {
     return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->via('tagRelation');
 }