コード例 #1
0
 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]);
     }
 }
コード例 #2
0
ファイル: Artikel.php プロジェクト: cakpep/spk-tht
 public function getArtikelKomentars()
 {
     return $this->hasMany(\frontend\models\ArtikelKomentar::className(), ['artikel_id' => 'id']);
 }