Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionCreate()
- {
- if(Yii::$app->user->identity->status==User::USER)
- {
- throw new HttpException(403, "Access Denied");
- }
- $model = new User();
- if ($model->load(Yii::$app->request->post()) && $model->validate()) {
- $model->password = md5($model->password);
- $location = Locations::find()->andFilterWhere(['and',
- ['=', 'zip_code', $model->zip],
- ['like', 'street_name', $model->street],
- ['like', 'district', $model->district],
- ])->all();
- $model->location_id=$location[0]->id;
- if($model->save())
- {
- Yii::$app->session->setFlash('success', common::translateText("ADD_SUCCESS"));
- }
- else{
- Yii::$app->session->setFlash('error', common::translateText("ADD_FAIL"));
- }
- return $this->redirect(['index']);
- } else {
- return $this->render('_form', [
- 'model' => $model,
- ]);
- }
- }
Add Comment
Please, Sign In to add comment