Esempio n. 1
0
 /**
  * @return bool
  */
 public function add()
 {
     $model = new TimeLine();
     $model->icon = $this->icon;
     $model->category = $this->category;
     $model->event = $this->event;
     $model->data = json_encode($this->data, JSON_UNESCAPED_UNICODE);
     return $model->save(false);
 }
Esempio n. 2
0
 public function actionEditor()
 {
     $data = Yii::$app->request->post();
     $model = new TimeLine();
     $user_id = Yii::$app->user->identity->id;
     if (!empty($data['title']) && !empty($data['content'])) {
         $model->user_id = $user_id;
         $model->post_title = $data['title'];
         $model->post = $data['content'];
         $model->posted_time = date("j F Y H:m");
         $model->save();
     }
     if (!empty($data['last_post'])) {
         $sql = 'SELECT * FROM `time_line` WHERE `post_id`>' . $data['last_post'] . ' and  `user_id`=' . $user_id . '';
         $res = $model->findBySql($sql)->asArray()->all();
         return json_encode($res);
     } else {
         $res = $model->find()->where(['`user_id`' => $user_id])->asArray()->all();
         return json_encode($res);
     }
 }