public function actionDelete() { $id = Yii::$app->request->get('id'); if ($id > 0) { if (Warning::deletePicture($id)) { Warning::deleteAll(['id' => $id]); } } return $this->redirect(['index']); }
public function actionDelete($id) { $id = Yii::$app->request->get('id'); if ($id > 0) { // delete equipment status DcEquipmentStatus::deleteAll(['station_id' => $id]); // delete sensor status SensorStatus::deleteAll(['station_id' => $id]); // delete dc equipment status DcEquipmentStatus::deleteAll(['station_id' => $id]); // delete power status PowerStatus::deleteAll(['station_id' => $id]); // delete station status StationStatus::deleteAll(['station_id' => $id]); // delete station status controller StationStatusHandler::deleteAll(['station_id' => $id]); // delete warning $warnings = Warning::findAll(['station_id' => $id]); if (!empty($warnings)) { foreach ($warnings as $w) { Yii::$app->db->createCommand()->delete('warning_picture', ['warning_id' => $w['id']])->execute(); } } Warning::deleteAll(['station_id' => $id]); // delete station Station::deleteAll(['id' => $id]); //write log action Log::logControl(Yii::$app->user->id, Log::ACTION_DELETE_STATION, $id); } return $this->redirect(['index']); }