/** * Deletes an existing Template model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); Option::deleteAll(['template_id' => $id]); $model->delete(); Yii::$app->getSession()->setFlash('template-delete-success'); return $this->redirect(['index']); }