public function actionRemove($id = null) { $vendor = Vendor::find()->where(['id' => $id])->one(); $vendor_image = new VendorImage(); $vendor_image->Remove($vendor->image_name); Vendor::deleteAll(['id' => $id]); Yii::$app->getSession()->setFlash('success', Yii::t('shop', 'All changes have been saved')); return $this->redirect(Url::toRoute('/shop/vendor')); }
/** * @return \yii\db\ActiveQuery */ public function getVendor() { return $this->hasOne(Vendor::className(), ['id' => 'vendor_id']); }