/** * Creates a new MUser model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new MUser(); 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 actionCreate() { $model = new MUser(); if (\Yii::$app->request->isPost) { $model->load(\Yii::$app->request->post()); if ($model->save()) { return $this->redirect(['index']); } else { U::W($model->getErrors()); } } return $this->render('create', ['model' => $model]); }
public function actionLuck() { $this->layout = 'wap'; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($model === null) { $model = new MUser(); $subscribed = false; } else { if ($model->subscribe) { $subscribed = true; } else { $subscribed = false; } } if (!Yii::$app->user->isGuest) { $username = Yii::$app->user->identity->username; } else { $username = ''; } $result = ''; $lucy_msg = []; if ($model->load(Yii::$app->request->post())) { if (Yii::$app->user->isGuest) { $username = $model->mobile; } $loca = file_get_contents("http://api.showji.com/Locating/www.show.ji.c.o.m.aspx?m=" . $model->mobile . "&output=json&callback=querycallback"); $loca = substr($loca, 14, -2); $loca = json_decode($loca, true); $lucy_msg = U::getMobileLuck($model->mobile); $lucy_msg['Mobile'] = $model->mobile; $result = $this->renderPartial('luck_result', ['loca' => $loca, 'lucy_msg' => $lucy_msg]); } return $this->render('luck', ['model' => $model, 'result' => $result, 'lucy_msg' => $lucy_msg, 'subscribed' => $subscribed, 'username' => $username]); }