Esempio n. 1
0
 /**
  * Creates a new Concerns model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Concerns();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 public function actionAdd()
 {
     $data = Yii::$app->request->post();
     //var_dump($data);
     if (isset($data['myphone']) && isset($data['concernphone'])) {
         $u1 = Users::find()->where(['phone' => $data['myphone']])->one();
         $u2 = Users::find()->where(['phone' => $data['concernphone']])->one();
         if (Concerns::findAll(['myid' => $u1['id'], 'concernid' => $u2['id']])) {
             return array('flag' => 1, 'msg' => 'is already concern!');
         }
         $co = new Concerns();
         $co->myid = $u1['id'];
         $co->concernid = $u2['id'];
         $co->created_at = time();
         $co->save();
         $u2->concerncount++;
         $u2->save();
         return array('flag' => 1, 'msg' => 'add concern success!');
     } else {
         return array('flag' => 0, 'msg' => 'arg not enough!');
     }
 }