public function actionVendorupdate() { //$this->layout = "@app/views/layouts/vendor"; $this->layout = "@app/views/layouts/vendor_left"; $model = new VendorRegister(); $userData = VendorRegister::find()->where(['uid' => Yii::$app->user->id])->one(); $userMain = UserMaster::find()->where(['id' => Yii::$app->user->id])->one(); $model->countriesList = Countries::getCountriesUS(); if ($userData['country'] == NULL) { $model->country = 231; } else { $model->country = $userData['country']; } $model->statesData = Countries::getStatesByCountryDefault($model->country); if ($userData['state'] == NULL) { $model->state = 3975; } else { $model->state = $userData['state']; } if ($model->load(Yii::$app->request->post())) { $model->uid = Yii::$app->user->id; //$model->dob = 'NOW()'; $userExist = VendorRegister::find()->where(['uid' => Yii::$app->user->id])->one(); if ($userExist != NULL) { //echo "00000000000000000"; $userExist->firstName = $model->firstName; $userExist->lastName = $model->lastName; $userExist->middleName = $model->middleName; $userExist->mobile = $model->mobile; $userExist->mobile2 = $model->mobile2; $userExist->address2 = $model->address2; $userExist->city = $model->city; $userExist->state = $model->state; $userExist->country = $model->country; $userExist->zip = $model->zip; $userExist->businessName2 = $model->businessName2; $userExist->fax = $model->fax; $userExist->modifiedDate = 'NOW()'; if ($userMain->roleId == 2) { $userExist->storeName = $model->storeName; $userExist->storeAddress = $model->storeAddress; $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; $userExist->storeImage = $model->storeImage; $model->storeImage; } } $userExist->update(); //print_r($userExist);exit(); Yii::$app->getSession()->setFlash('success', 'You are successfully Updated Your Profile.'); return $this->redirect(['profile']); } else { $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; $userExist->storeImage = $model->storeImage; $model->storeImage; } $model->email = '*****@*****.**'; $model->save(); Yii::$app->getSession()->setFlash('success', 'You are successfully Updated Your Profile.'); return $this->redirect(['profile']); } } else { $model->email = $userMain->email; $model->roleId = $userMain->roleId; $model->firstName = $userData['firstName']; $model->lastName = $userData['lastName']; $model->middleName = $userData['middleName']; $model->mobile = $userData['mobile']; $model->mobile2 = $userData['mobile2']; $model->address2 = $userData['address2']; $model->city = $userData['city']; $model->state = $userData['state']; $model->country = $userData['country']; if ($model->country == '') { $model->country = 231; } $model->zip = $userData['zip']; $model->storeName = $userData['storeName']; $model->storeAddress = $userData['storeAddress']; $model->storeImage = $userData['storeImage']; $model->businessName2 = $userData['businessName2']; $model->fax = $userData['fax']; $model->vendor_unique_id = $userData['vendor_unique_id']; return $this->render('vendorprofileedit', ['model' => $model]); } //end else }
public function getU() { return $this->hasOne(UserMaster::className(), ['id' => 'uid']); }
public function actionVendor() { //$this->layout='profile'; $model = new RegisterMaster(); $userMain = UserMaster::find()->where(['id' => Yii::$app->user->id])->one(); if ($model->load(Yii::$app->request->post())) { $model->uid = Yii::$app->user->id; $userMain = UserMaster::find()->where(['id' => Yii::$app->user->id])->one(); if ($userMain != NULL) { $userMain->roleId = 2; $userMain->email = $model->email; $userMain->save(); } // echo $model->dob = date('Y-m-d h:m:s'); $userExist = RegisterMaster::find()->where(['uid' => Yii::$app->user->id])->one(); //echo "<pre>"; print_r($userExist); if ($userExist != NULL) { $userExist->storeName = $model->storeName; $userExist->storeAddress = $model->storeAddress; $userExist->firstName = $model->firstName; $userExist->lastName = $model->lastName; $userExist->middleName = $model->middleName; $userExist->gender = $model->gender; $userExist->dob = $model->dob; $userExist->mobile = $model->mobile; $userExist->mobile2 = $model->mobile2; $userExist->address1 = $model->address1; $userExist->address2 = $model->address2; $userExist->city = $model->city; $userExist->state = $model->state; $userExist->country = $model->country; $userExist->zip = $model->zip; $userExist->modifiedDate = 'NOW()'; $model->storeImage = UploadedFile::getInstance($model, 'storeImage'); if ($model->storeImage != '') { $imageName = rand(1000, 100000) . $model->storeImage->baseName; $model->storeImage->saveAs('uploads/storeimages/' . $imageName . '.' . $model->storeImage->extension); $model->storeImage = 'uploads/storeimages/' . $imageName . '.' . $model->storeImage->extension; $userExist->storeImage = $model->storeImage; $model->storeImage; } /***************************/ $userExist->modifiedDate = date('Y-m-d h:m:s'); $userExist->save(); Yii::$app->getSession()->setFlash('success', 'You are successfully Updated Your Profile.'); return $this->redirect(['profile']); } else { $model->save(); Yii::$app->getSession()->setFlash('success', 'You are successfully Updated Your Profile.'); return $this->redirect(['profile']); } } else { $userData = RegisterMaster::find()->where(['uid' => Yii::$app->user->id])->one(); $model->email = $userMain->email; $model->roleId = $userMain->roleId; $model->firstName = $userData['firstName']; $model->lastName = $userData['lastName']; $model->middleName = $userData['middleName']; $model->gender = $userData['gender']; //$model->email = $userData['email']; $model->dob = $userData['dob']; $model->mobile = $userData['mobile']; $model->mobile2 = $userData['mobile2']; $model->address1 = $userData['address1']; $model->address2 = $userData['address2']; $model->city = $userData['city']; $model->state = $userData['state']; $model->country = $userData['country']; $model->zip = $userData['zip']; $model->storeName = $userData['storeName']; $model->storeAddress = $userData['storeAddress']; $model->file = $userData['file']; return $this->render('vendor', ['model' => $model]); } }