public function actionView($id) { $comment = new ArtikelKomentar(); if ($comment->load(Yii::$app->request->post())) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $comment->artikel_id = $id; $comment->user_id = Yii::$app->user->id; $comment->komentar_oleh = Yii::$app->user->id; $comment->komentar_waktu = date('Y-m-d H:i:s'); if ($comment->save()) { $res = array('message' => 'Data Berhasil Di Simpan.', 'alert' => 'success', 'proses' => 'save', 'success' => true); } else { $res = array('message' => 'Data Gagal Di Simpan.', 'alert' => 'error', 'proses' => 'save', 'success' => false); } return $res; \Yii::$app->end(); } else { return $this->renderAjax('view', ['model' => $this->findModel($id), 'comment' => $comment]); } }
public function getArtikelKomentars() { return $this->hasMany(\frontend\models\ArtikelKomentar::className(), ['artikel_id' => 'id']); }