/** * Finds the Formlaporan model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Formlaporan the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Formlaporan::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionHapusform($id) { $form = Formlaporan::findOne(['id_output' => $id]); /* Delete model file */ unlink(Yii::getAlias('@vendor/kemdikbud/yii2-target-output/models/') . $form->nama_class . '.php'); /* Delete model file */ /* Delete table */ $string = 'DROP TABLE ' . $form->nama_tabel; Yii::$app->db->createCommand($string)->execute(); /* Delete table */ Formlaporan::deleteAll('id_output = ' . $id); return $this->redirect(['view', 'id' => $id]); }