Example #1
0
 public static function add($key, $type, $value)
 {
     $info = new Info();
     $info->key = $key;
     $info->type = $type;
     $info->value = $value;
     return $info->save();
 }
Example #2
0
 /**
  * Creates a new Info model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Info();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('info-form', ['model' => $model]);
     }
 }
Example #3
0
 public function actionAddData()
 {
     $model = new Info();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         $model->created_by = Yii::$app->user->id;
         $model->created_date = date('Y-m-d H:i:s');
         if ($model->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('create', ['model' => $model]);
     }
 }
Example #4
0
 public function actionInfo()
 {
     $info = file_get_contents('php://input');
     if ($info = json_decode($info, true)) {
         foreach ($info as $key => $value) {
             $model = Info::findOne(['key' => $key, 'client_id' => $this->client_user->id]);
             if (!$model instanceof Info) {
                 $model = new Info();
             }
             $model->key = $key;
             $model->value = $value;
             if ($this->client_user instanceof ClientUsers) {
                 $model->client_id = $this->client_user->id;
             }
             $model->save();
         }
     } else {
         throw new HttpException(400, 'Invalid info');
     }
 }
Example #5
0
 /**
  * Creates a new Info model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     $this->layout = 'create_list';
     $model = new Info();
     if (Yii::$app->request->isPost) {
         $model->category_id = $id;
         $model->time = time();
         $model->user_id = 1;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // ) {
         $model->move_images();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $view = Info::get_view($id);
         return $this->render('create', ['model' => $model, 'view' => $view, 'id' => $id]);
     }
 }