Ejemplo n.º 1
0
 public function actionStaffbind($gh_id, $openid)
 {
     if (Yii::$app->request->isAjax) {
         U::W('is ajax....');
     }
     $this->layout = 'wapx';
     $mobile = $_GET['mobile'];
     $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     if ($model === null) {
         $model = MStaff::findOne(['mobile' => $mobile]);
         if ($model === null) {
             $model = new MStaff();
         }
         $model->gh_id = $gh_id;
         $model->openid = $openid;
         $model->mobile = $mobile;
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             return $this->redirect(['staffhome', 'gh_id' => $gh_id, 'openid' => $openid]);
         } else {
             U::W($model->getErrors());
         }
     }
     return $this->render('staffbind', ['model' => $model]);
 }
Ejemplo n.º 2
0
 public function actionStaffcreate()
 {
     $model = new MStaff();
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $model->gh_id = Yii::$app->user->getGhid();
         if ($model->save()) {
             return $this->redirect(['stafflist']);
         } else {
             U::W($model->getErrors());
         }
     }
     return $this->render('staffcreate', ['model' => $model]);
 }