当前位置: 首页>>代码示例>>PHP>>正文


PHP Customer::validate方法代码示例

本文整理汇总了PHP中Customer::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::validate方法的具体用法?PHP Customer::validate怎么用?PHP Customer::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer::validate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 public function actionCreate()
 {
     // if some data has been entered before or the user is already logged in,
     // take the already existing data and prefill the input form
     if ($model = Shop::getCustomer()) {
         $address = $model->address;
     } else {
         $model = new Customer();
     }
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if (isset($_POST['Address'])) {
             $address = new Address();
             $address->attributes = $_POST['Address'];
             if ($address->save()) {
                 $model->address_id = $address->id;
             }
         }
         if (!Yii::app()->user->isGuest) {
             $model->user_id = Yii::app()->user->id;
         }
         $model->validate();
         if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
             if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
                 if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
                     $model->addError('password', Shop::t('Passwords do not match'));
                 } else {
                     if ($_POST['Customer']['password'] == '') {
                         $model->addError('password', Shop::t('Password is empty'));
                     } else {
                         $user = new YumUser();
                         $profile = new YumProfile();
                         $profile->attributes = $_POST['Customer'];
                         $profile->attributes = $_POST['Address'];
                         if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
                             $user->status = YumUser::STATUS_ACTIVE;
                             $user->save(false, array('status'));
                             $model->user_id = $user->id;
                             Shop::setFlash(Shop::t('Successfully registered user'));
                         } else {
                             $model->addErrors($user->getErrors());
                             $model->addErrors($profile->getErrors());
                             Shop::setFlash(Shop::t('Error while registering user'));
                         }
                     }
                 }
             }
         }
         if (!$model->hasErrors()) {
             if ($model->save()) {
                 Yii::app()->user->setState('customer_id', $model->customer_id);
                 $this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
             }
         }
     }
     $this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
 }
开发者ID:axetion007,项目名称:yii-shop,代码行数:57,代码来源:CustomerController.php

示例2: action_do_create

 public function action_do_create()
 {
     $v = Customer::validate(Input::all());
     if ($v->fails()) {
         return Redirect::to_route('create_customer')->with('user', Auth::user())->with_errors($v)->with_input();
     }
     $new_customer = array('name' => Input::get('name'), 'description' => Input::get('description'), 'organization_id' => Auth::user()->organization->id);
     $customer = new Customer($new_customer);
     $customer->save();
     return Redirect::to_route('customers');
 }
开发者ID:nigobo,项目名称:laravel-play,代码行数:11,代码来源:customer.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (CustomerType::model()->count('active=1') == 0) {
         throw new CHttpException(412, 'No hay tipos de clientes activos. Para crear un cliente, primero debe ' . CHtml::link('crear un tipo de cliente', array('customerType/create')) . '.');
     }
     $model = new Customer();
     $model->contact = new Contact();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         $model->dependence_id = $model->dependence_id == '' ? NULL : $model->dependence_id;
         $model->contact->active = $model->active;
         if (isset($_POST['Contact'])) {
             $model->contact->attributes = $_POST['Contact'];
             $successful = $model->contact->validate();
         }
         $successful = $model->validate() && $successful;
         if ($successful) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if ($model->save(false)) {
                     $model->contact->customer_id = $model->id;
                     if ($model->contact->save(false)) {
                         $transaction->commit();
                         if (!empty($_POST['yt1'])) {
                             Yii::app()->user->setFlash('customer-created', "¡El cliente <b><i>&quot;{$model->name}&quot;</i></b> fue creado exitosamente!");
                             $this->redirect(array('create'));
                         } else {
                             $this->redirect(array('view', 'id' => $model->id));
                         }
                     }
                 }
                 $transaction->rollBack();
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:rodespsan,项目名称:LMEC,代码行数:45,代码来源:CustomerController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Customer();
     $profile = new Profile();
     $address = new CheckoutAddress();
     //Yii::app()->session['cid'] = '';
     $this->performAjaxValidation(array($model, $profile), 'customer-form');
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         $profile->attributes = $_POST['Profile'];
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate() && $this->validateAddress()) {
             $realp = PasswordHelper::generateStrongPassword();
             $model->password = $realp;
             $model->activkey = PasswordHelper::hashPassword(microtime() . $model->password);
             $model->password = PasswordHelper::hashPassword($model->password);
             $model->status = 0;
             $model->type = 1;
             if ($model->save()) {
                 Yii::app()->session['cid'] = $model->id;
                 $profile->user_id = $model->id;
                 $profile->save();
                 if (!empty($_POST['Customer']['c_group_id'])) {
                     foreach ($_POST['Customer']['c_group_id'] as $groupid) {
                         $customerGroup = new CustomerCGroup();
                         $customerGroup->user_id = $model->id;
                         $customerGroup->c_group_id = $groupid;
                         $customerGroup->save();
                     }
                 }
                 $passwordHistory = new PasswordHistory();
                 $passwordHistory->profile_id = $model->id;
                 $passwordHistory->password = $model->password;
                 $passwordHistory->save();
                 foreach ($this->_address as $address) {
                     $address->user_id = $model->id;
                     $address->save();
                 }
                 if (Yii::app()->getModule('user')->sendActivationMail) {
                     $activation_url = $this->createAbsoluteUrl('/user/activation', array("activkey" => $model->activkey, "email" => $model->email));
                     UserModule::sendMail($model->email, UserModule::t("Your {site_name} account has been created", array('{site_name}' => Yii::app()->name)), UserModule::t("To activate your account, go to <a href='{activation_url}'>{activation_url}</a>.<br/><br/>Username: " . $model->username . "<br/>Password: " . $realp . "<br/>", array('{activation_url}' => $activation_url)));
                 }
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, Yii::t('info', 'Customer was successfully created'));
                 $this->renderPartial('_view', array('model' => $model, 'profile' => $profile, 'address' => $this->_address), false, true);
                 Yii::app()->end();
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, Yii::t('info', 'An error occurred while trying to create new customer, please try again.'));
                 /*$this->render('create',array(
                 			'model'=>$model,
                 			'profile'=>$profile,
                 		));*/
             }
         } else {
             $profile->validate();
             $this->validateAddress();
             //echo GxActiveForm::validateMultiple(array($model,$profile,$address));
             //Yii::app()->end();
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form_address', array('model' => $model, 'profile' => $profile, 'address' => $this->_address), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'profile' => $profile, 'address' => $this->_address));
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:69,代码来源:CustomerController.php

示例5: actionPay

 public function actionPay()
 {
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->loginRequired();
     }
     $model = Customer::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
     if ($model === null) {
         $model = new Customer();
     }
     /* unset($model->attributes);
        $model->user_id  = Yii::app()->user->id; */
     // uncomment the following code to enable ajax-based validation
     /*
      if(isset($_POST['ajax']) && $_POST['ajax']==='customer-_customer-form')
      {
     echo CActiveForm::validate($model);
     Yii::app()->end();
     }
     */
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if ($model->validate() && $model->save()) {
             $this->redirect($this->createUrl('cartdetail'));
         }
     }
     $this->render('_customer', array('model' => $model));
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:27,代码来源:ProductController.php

示例6: actionSignup

 /**
  * Handles the first page of the application form
  * @param string $city
  */
 public function actionSignup($city)
 {
     $customer_model = new Customer();
     $commande_model = new Commande();
     $goodcity = Goodcity::model()->findByPk($city);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     // Set the scenario to limit the attributes we suck in from
     //  the POST array.  This protects us against injection attacks.
     $commande_model->setScenario('user_create');
     $customer_model->setScenario('user_create');
     if (isset($_POST['Customer'])) {
         // Populate our new models from the input arrays
         $customer_model->attributes = $_POST['Customer'];
         $commande_model->attributes = $_POST['Commande'];
         // If a model saves, we know it's valid
         if ($customer_model->validate()) {
             // Save the uploaded files
             $arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
             foreach ($arr_uploads as $upload) {
                 $commande_model->{'t' . $upload} = CUploadedFile::getInstance($commande_model, $upload);
             }
             // We have to insert a dummy id here to run validate()
             $commande_model->bilkey = 0;
             if ($commande_model->validate()) {
                 // Save the uploaded files
                 $arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
                 foreach ($arr_uploads as $upload) {
                     $commande_model->{$upload} = CUploadedFile::getInstance($commande_model, $upload);
                     if ($commande_model->{$upload} != null) {
                         $path = $this->getUploadPath($commande_model->{$upload});
                         $commande_model->{$upload}->saveAs($path);
                         $_POST['Commande'][$upload] = $path;
                     }
                 }
                 // We don't actually want to do the save just yet,
                 //  so store *everything* in the session.  (This is hack-y)
                 Yii::app()->user->setState('Customer', $_POST['Customer']);
                 Yii::app()->user->setState('Commande', $_POST['Commande']);
                 Yii::app()->user->setState('payment_type', $_POST['payment']);
                 //var_dump($this->emailValidation($customer_model));die();
                 if ($this->passwordUsernameVerification($customer_model) == false) {
                     $this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'username_used' => true));
                     die;
                 } elseif ($this->emailValidation($customer_model) == false) {
                     $this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'email_used' => true));
                     die;
                 }
                 $this->redirect(array('order'));
             }
         } else {
             // We have to insert a dummy id here to run validate()
             $commande_model->bilkey = 0;
             $commande_model->validate();
         }
     } elseif (isset(Yii::app()->user->Customer)) {
         $customer_model->attributes = Yii::app()->user->Customer;
         $commande_model->attributes = Yii::app()->user->Commande;
         //    		$payment_type               = Yii::app()->user->payment_type;
     }
     // Hack for one-time setup option
     $onetime = false;
     if (isset(Yii::app()->user->onetime)) {
         $onetime = true;
     } else {
         $onetime = false;
     }
     $this->render('application/1-signup', array('customer_model' => $customer_model, 'commande_model' => $commande_model, 'goodcity' => $goodcity, 'onetime' => $onetime));
 }
开发者ID:E-SOFTinc,项目名称:Mailnetwork_Yii,代码行数:73,代码来源:UserController.php

示例7: validateCustomer

 public function validateCustomer()
 {
     if (isset($_POST['Customer'])) {
         $valid = true;
         $this->_productattribute = array();
         /*Yii::log( "ProductCreateAction: ".CVarDumper::dumpAsString( $_POST['ProductOption'] ),
         			CLogger::LEVEL_ERROR, "product.actions.create" 
         		);*/
         $customer = new Customer();
         $customer->attributes = $_POST['Customer'];
         $valid = $customer->validate() && $valid;
         $this->_ordercustomer = $customer;
         if (!$valid) {
             return false;
         }
     }
     return true;
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:18,代码来源:OrderController.php

示例8: postCustomerAdd

 public function postCustomerAdd($id = "")
 {
     $input = \Input::get();
     $validation = \Customer::validate($input);
     if ($id != "") {
         $customer = \Customer::find($id);
         array_forget($input, "_token");
         array_forget($input, "confirm");
         array_forget($input, "submit");
         array_forget($input, "tag");
         foreach ($input as $key => $value) {
             $customer->{$key} = $value;
         }
         if ($customer->update()) {
             \Session::put("success_message", "Customer record updeted!");
             return \Redirect::back();
         } else {
             \Session::put("error_message", "Unexpected Error! Customer record could not be updated");
             return \Redirect::back()->withInput();
         }
         exit;
     } else {
     }
     if ($validation->fails()) {
         return \Redirect::back()->withErrors($validation)->withInput();
     } else {
         $customer = new \Customer();
         array_forget($input, "_token");
         array_forget($input, "confirm");
         array_forget($input, "submit");
         array_forget($input, "tag");
         foreach ($input as $key => $value) {
             $customer->{$key} = $value;
         }
         $customer->password = \Hash::make(\Input::get("password"));
         if ($customer->save()) {
             \Mail::send('emails.registration', $input, function ($message) use($input) {
                 $message->from("info@melkaycosmetics.com", "Melkay Cosmetics ");
                 $message->to($input['email'], "info@melkaycosmetics.com")->cc('ahmed@chroniclesoft.com')->subject("Registration ");
             });
             \Session::put("success_message", "Your Registration was successful");
             return \Redirect::back();
         } else {
             \Session::put("error_message", "Your registration was not successful, please try again next time");
             return \Redirect::back()->withInput();
         }
         //}
     }
 }
开发者ID:runningjack,项目名称:auctionsite,代码行数:49,代码来源:SalesController.php

示例9: postRegister

 public function postRegister()
 {
     $validation = Customer::validate(Input::all());
     $input = Input::all();
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         $customer = new Customer();
         if (isset($input['ship_billing'])) {
             $customer->shipping_firstname = $input['firstname'];
             $customer->shipping_lastname = $input['lastname'];
             $customer->shipping_company = $input['company'];
             $customer->shipping_address_1 = $input['apartment'];
             $customer->shipping_address_2 = $input['address'];
             $customer->shipping_city = $input['city'];
             $customer->shipping_country = $input['country'];
         }
         array_forget($input, "_token");
         array_forget($input, "confirmpassword");
         array_forget($input, "submit");
         array_forget($input, "ship_billing");
         foreach ($input as $key => $value) {
             $customer->{$key} = $value;
         }
         $customer->password = Hash::make(Input::get("password"));
         if ($customer->save()) {
             Mail::send('emails.registration', $input, function ($message) use($input) {
                 $message->from("info@medicalequipment-ng.com", "Medical Equipment NG");
                 $message->to($input['email'], "info@medicalequipment-ng.com")->cc('ahmed@chroniclesoft.com')->subject("Registration ");
             });
             Session::put("success_message", "Your Registration was successful");
             return Redirect::back();
         } else {
             Session::put("error_message", "Your registration was not successful, please try again next time");
             return Redirect::back();
         }
     }
 }
开发者ID:runningjack,项目名称:auctionsite,代码行数:38,代码来源:HomeController.php

示例10: actionConvertAddressBook

 /**
  * Extract shipping and billing address information, create address book and map to the carts
  */
 protected function actionConvertAddressBook()
 {
     $sql = "select * from xlsws_cart where billaddress_id IS NULL and address_bill IS NOT NULL order by id limit 500";
     $arrProducts = Yii::app()->db->createCommand($sql)->query();
     while (($result = $arrProducts->read()) !== false) {
         $result['email'] = strtolower($result['email']);
         //verify that Customer ID really exists in customer table
         $objCust = Customer::model()->findByPk($result['customer_id']);
         if (!$objCust instanceof Customer) {
             $result['customer_id'] = 0;
         }
         if (strlen($result['address_bill']) > 0) {
             $arrAddress = explode("\n", $result['address_bill']);
             if (count($arrAddress) == 5) {
                 //old format address, should be 6 pieces
                 $arrAddress[5] = $arrAddress[4];
                 $strSt = $arrAddress[3];
                 if ($strSt[0] == " ") {
                     //no state on this address
                     $arrAddress[4] = substr($strSt, 1, 100);
                     $arrAddress[3] = "";
                 } else {
                     $arrSt = explode(" ", $strSt);
                     $arrAddress[3] = $arrSt[0];
                     $arrAddress[4] = str_replace($arrSt[0] . " ", "", $strSt);
                 }
             }
             $objAddress = new CustomerAddress();
             if (count($arrAddress) >= 5) {
                 $objCountry = Country::LoadByCode($arrAddress[5]);
                 if ($objCountry) {
                     $objAddress->country_id = $objCountry->id;
                     $objState = State::LoadByCode($arrAddress[3], $objCountry->id);
                     if ($objState) {
                         $objAddress->state_id = $objState->id;
                     }
                 }
                 $objAddress->address1 = $arrAddress[0];
                 $objAddress->address2 = $arrAddress[1];
                 $objAddress->city = $arrAddress[2];
                 $objAddress->postal = $arrAddress[4];
                 $objAddress->first_name = $result['first_name'];
                 $objAddress->last_name = $result['last_name'];
                 $objAddress->company = $result['company'];
                 $objAddress->phone = $result['phone'];
                 $objAddress->residential = CustomerAddress::RESIDENTIAL;
                 $objAddress->created = $result['datetime_cre'];
                 $objAddress->modified = $result['datetime_cre'];
                 $objAddress->active = 1;
                 if (empty($objAddress->address2)) {
                     $objAddress->address2 = null;
                 }
                 if (empty($objAddress->company)) {
                     $objAddress->company = null;
                 }
                 $blnFound = false;
                 if ($result['customer_id'] > 0) {
                     //See if this is already in our database
                     $objPriorAddress = CustomerAddress::model()->findByAttributes(array('address1' => $objAddress->address1, 'address2' => $objAddress->address2, 'city' => $objAddress->city, 'postal' => $objAddress->postal, 'first_name' => $objAddress->first_name, 'last_name' => $objAddress->last_name, 'company' => $objAddress->company, 'phone' => $objAddress->phone));
                     if ($objPriorAddress instanceof CustomerAddress) {
                         Yii::app()->db->createCommand("update xlsws_cart set billaddress_id=" . $objPriorAddress->id . " where id=" . $result['id'])->execute();
                         $blnFound = true;
                     } else {
                         $objAddress->customer_id = $result['customer_id'];
                     }
                 } else {
                     //We need a shell customer record just for the email
                     $objC = Customer::model()->findByAttributes(array('email' => $result['email']));
                     if ($objC instanceof Customer) {
                         Yii::app()->db->createCommand("UPDATE xlsws_cart set customer_id=" . $objC->id . " where id=" . $result['id'])->execute();
                     } else {
                         $objC = new Customer();
                         $objC->record_type = Customer::GUEST;
                         $objC->email = $result['email'];
                         $objC->first_name = $objAddress->first_name;
                         $objC->last_name = $objAddress->last_name;
                         $objC->company = $objAddress->company;
                         if (!$objC->validate()) {
                             $arrErr = $objC->getErrors();
                             if (isset($arrErr['email'])) {
                                 $objC->email = $result['id'] . ".invalid@example.com";
                             }
                             if (!$objC->validate()) {
                                 return print_r($objC->getErrors(), true);
                             }
                         }
                         if (!$objC->save()) {
                             Yii::log("Import Error " . print_r($objC->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                             return print_r($objC->getErrors(), true);
                         } else {
                             $cid = $objC->id;
                         }
                         Yii::app()->db->createCommand("UPDATE xlsws_cart set customer_id=" . $cid . " where id=" . $result['id'])->execute();
                     }
                     $result['customer_id'] = $objC->id;
                     $objAddress->customer_id = $result['customer_id'];
                 }
//.........这里部分代码省略.........
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:101,代码来源:InstallController.php

示例11: validateCustomer

 public function validateCustomer()
 {
     if (isset($_POST['Customer'])) {
         $customer = new Customer();
         $profile = new Profile();
         $customer->attributes = $_POST['Customer'];
         $profile->attributes = $_POST['Profile'];
         $valid = $customer->validate();
         $valid = $profile->validate() && $valid;
         $this->_ordercustomer = $customer;
         $this->_orderprofile = $profile;
         if (!$valid) {
             return false;
         }
     }
     return true;
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:17,代码来源:OrderController.php


注:本文中的Customer::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。