public function actionCreate() { $model = new Faktur(); if ($model->load(Yii::$app->request->post())) { try { $picture = UploadedFile::getInstance($model, 'foto'); $model->foto = 'FAKTUR - ' . $_POST['Faktur']['nama_penerima'] . '-' . $_POST['Faktur']['tgl_faktur'] . '.' . $picture->extension; if ($model->save()) { $picture->saveAs('uploads/faktur/' . 'FAKTUR - ' . $model->nama_penerima . '-' . $model->tgl_faktur . '.' . $picture->extension); Yii::$app->getSession()->setFlash('success', 'Data saved!'); $id_faktur = $model->id; $no_faktur = $model->no_faktur; $user = Yii::$app->user->identity->username; Yii::$app->db->createCommand('insert into logs (date, logs) VALUES (now(),"Insert data faktur dengan id : ' . $id_faktur . ' (' . $no_faktur . ') // oleh user : '******'")')->execute(); return $this->redirect(['view', 'id' => $model->id]); } else { Yii::$app->getSession()->setFlash('error', 'Data not saved!'); //var_dump($_POST); return $this->render('create', ['model' => $model]); } } catch (Exception $e) { Yii::$app->getSession()->setFlash('error', "{$e->getMessage()}"); } } else { return $this->render('create', ['model' => $model]); } }