SaveImgBehavior::className(), 'fields' => [ [ 'name' => 'image', 'directory' => 'category_purpose', ], ], ], ]; } /** * @inheritdoc */ public function rules() { return [ [['category_id', 'purpose_id'], 'required'], [['category_id', 'purpose_id'], 'integer'], [['image'], 'string', 'max' => 255], [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], [['purpose_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxOption::className(), 'targetAttribute' => ['purpose_id' => 'tax_option_id']], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'category_id' => Yii::t('app', 'Category ID'), 'purpose_id' => Yii::t('app', 'Purpose ID'), 'image' => Yii::t('app', 'Image'), ]; } /** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(Category::className(), ['category_id' => 'category_id']); } /** * @return \yii\db\ActiveQuery */ public function getPurpose() { return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'purpose_id']); } }