/** * Deletes an existing Patient model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionDelete($id) { if (Yii::$app->request->isAjax) { $transaction = Yii::$app->db->beginTransaction(); try { $Glaukuchet = Glaukuchet::findOne(['id_patient' => $id]); if (!empty($Glaukuchet)) { Glprep::deleteAll(['id_glaukuchet' => $Glaukuchet->primaryKey]); Glaukuchet::deleteAll(['id_patient' => $id]); } echo $this->findModel($id)->delete(); $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); throw new Exception($e->getMessage()); } } }