/** * Creates a new Keluarga model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Keluarga(); if ($model->load(Yii::$app->request->post())) { $no_kk = substr($model->kepala_keluarga, 0, 6) . Yii::$app->formatter->asDate('now', 'ddMMyy') . $model->id; $model->id = $no_kk; $model->tanggal_terbit = date('Y-m-d'); $model->tanggal_pembaruan = date('Y-m-d'); $model->status = 1; $updatable = BaseUpdatable::findOne($model->kepala_keluarga); $updatable->no_kk = $no_kk; $updatable->status_keluarga = 1; //echo var_dump($model); if ($model->save() && $updatable->save()) { $this->writeLog("Membuat kartu keluarga dengan nomor KK {$keluarga->id}"); return $this->redirect(['view', 'id' => $model->id]); } else { VarDumper::dump($model->getErrors(), 5678, true); //return $this->actionIndex(); } } else { return $this->renderAjax('create', ['model' => $model]); } }
/** * Finds the BaseUpdatable model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return BaseUpdatable the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModelUpdatable($id) { if (($model = BaseUpdatable::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Logs in a user. * * @return mixed */ public function actionUser($id) { $user = \common\models\BaseUpdatable::findOne($id)->foto; echo '<img src="' . $user . '" width="320px"/>'; }
/** * Get Data * @param string $nik * @return BaseUpdatable */ public function getData($nik) { return BaseUpdatable::findOne($nik); }