public function actionSignup() { $this->layout = "@app/views/layouts/vendor"; $model = new VendorRegister(); $userMain = new UserMaster(); $model->scenario = 'vendor'; $model->countriesList = Countries::getCountriesUS(); //$model->statesData = array(); $model->country = 231; $model->statesData = Countries::getStatesByCountryDefault($model->country); $model->state = 3975; if ($model->load(Yii::$app->request->post()) && $model->validate()) { $userSave = $model->signup(); $model->email = '*****@*****.**'; $model->username = '******'; $model->uid = $userSave->id; $model->storeImage = UploadedFile::getInstance($model, 'storeImage'); if ($model->storeImage != '') { $imageName = rand(1000, 100000) . $model->storeImage->baseName; $model->storeImage->saveAs(Yii::getAlias('@frontend') . '/web/uploads/storeimages/' . $imageName . '.' . $model->storeImage->extension); $model->storeImage = 'uploads/storeimages/' . $imageName . '.' . $model->storeImage->extension; } else { $model->storeImage = ''; } $stateShortName = States::getStateName($model->state); $words = explode(" ", $stateShortName); $stateName = ""; /* if(count($words >= 2)) { $k=0; foreach ($words as $w) { if($k <= 1) { $stateName .= $w[0]; } $k++; } } else { $stateName = substr($stateShortName,0,2); } */ $stateName = States::getStateCode($model->state); $cityName = substr($model->city, 0, 2); $cnt = VendorRegister::find()->where(['state' => $model->state])->count(); if ($cnt == 0) { $userupdatedId = 100; } else { $userupdatedId = 100 + $cnt; } $model->vendor_unique_id = strtoupper($stateName . 'gds' . $userupdatedId); //print_r($model->vendor_unique_id);exit(); $model->save(); Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.'); //echo "Registration successfully"; return $this->redirect(['index']); } else { return $this->render('signup', ['model' => $model]); } }