/**
  * Creates a new Tbmessages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Tbmessages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionSend()
 {
     $data = Yii::$app->request->post();
     $msg = new Tbmessages();
     $phone = Users::findOne(['phone' => $data['phone']]);
     // $msg->userid = Yii::$app->user->id;
     $msg->userid = $phone['id'];
     $msg->title = $data['title'];
     $msg->content = $data['content'];
     $msg->pictures = isset($data['pictures']) ? $data['pictures'] : "";
     $msg->created_at = time();
     // 		for($i=1;$i<=9;$i++){
     //         	$msg->setAttribute('picture'. $i, isset($data['picture' . $i])?$data['picture' . $i]:'');
     //         }
     if ($msg->save()) {
         return array('flag' => 1, 'msg' => 'Send success!');
     } else {
         return array('error' => $msg->errors, 'flag' => 0, 'msg' => 'Send fail!');
     }
 }