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


PHP Address::save方法代码示例

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


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

示例1: getLatLon

 /**
  * Get lat lon by address
  * @author Oleg D.
  */
 function getLatLon($address, $updateAddress = 0)
 {
     $addressString = $city = $state = $country = '';
     if (!empty($address['address'])) {
         $addressString = $address['address'] . ' ' . $address['address2'] . ' ' . $address['address3'];
         if (!empty($address['city'])) {
             $city = $address['city'];
         }
         if (!empty($address['Country']['name'])) {
             $country = $address['Country']['name'];
         } elseif (!empty($address['country_name'])) {
             $country = $address['country_name'];
         }
         if (!empty($address['Provincestate']['name'])) {
             $state = $address['Provincestate']['name'];
         } elseif (!empty($address['state_name'])) {
             $state = $address['state_name'];
         }
         App::import('Vendor', 'GoogleMapAPI', array('file' => 'class.GoogleMapAPI.php'));
         $map = new GoogleMapAPI();
         $map->setAPIKey(GOOGLE_MAP_KEY);
         $latLon = $map->getCoordsByAddress(trim($addressString), $city, $state, $country);
         if ($updateAddress && !empty($address['id']) && !empty($latLon['lat']) && !empty($latLon['lon'])) {
             $Address = new Address();
             $Address->save(array('id' => $address['id'], 'latitude' => $latLon['lat'], 'longitude' => $latLon['lon']));
         }
         return $latLon;
     } else {
         return false;
     }
 }
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:35,代码来源:AddressHelper.php

示例2: save

 function save($id = FALSE)
 {
     if ($_POST) {
         $about = new Address($id);
         // if($_FILES['image']['name'])
         // {
         // if($about->id){
         // $about->delete_file($about->id,'uploads/about_us/','image');
         // }
         // $_POST['image'] = $about->upload($_FILES['image'],'uploads/about_us/',260,195);
         // }
         // if($_FILES['imagemap']['name'])
         // {
         // if($about->id){
         // $about->delete_file($about->id,'uploads/about_us/','imagemap');
         // }
         // $_POST['imagemap'] = $about->upload($_FILES['imagemap'],'uploads/about_us/');
         // }
         $_POST['name'] = lang_encode($_POST['name']);
         $_POST['address'] = lang_encode($_POST['address']);
         $_POST['tel'] = lang_encode($_POST['tel']);
         $_POST['facebook'] = lang_encode($_POST['facebook']);
         $_POST['twitter'] = lang_encode($_POST['twitter']);
         $_POST['googleplus'] = lang_encode($_POST['googleplus']);
         $_POST['open'] = lang_encode($_POST['open']);
         $_POST['open2'] = lang_encode($_POST['open2']);
         //$_POST['service_time'] = lang_encode($_POST['service_time']);
         $_POST['detail'] = lang_encode($_POST['detail']);
         // $_POST['user_id'] = $this->session->userdata('id');
         $about->from_array($_POST);
         $about->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect('addresses/admin/addresses');
 }
开发者ID:unisexx,项目名称:drtooth,代码行数:35,代码来源:addresses.php

示例3: actionCreate

 public function actionCreate()
 {
     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;
         }
         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:huynhchanhuy,项目名称:yii_shopping,代码行数:26,代码来源:CustomerController.php

示例4: up

 public function up()
 {
     $this->addColumn($this->tableName, $this->columnName, 'int');
     /** @var $data Office[] */
     $data = Office::model()->findAll();
     $migratedAddresses = [];
     foreach ($data as $office) {
         $fullAddress = implode(' ', [$office->address1, $office->address2, $office->address3, $office->address4]);
         if (isset($migratedAddresses[$fullAddress])) {
             $office->addressId = $migratedAddresses[$fullAddress]->id;
             $office->save(false);
             continue;
         }
         $parts = explode(' ', $office->address1);
         $buildingNumber = array_shift($parts);
         $line2 = implode(' ', $parts);
         $address = new Address();
         $address->line1 = $buildingNumber;
         $address->line2 = $line2;
         $address->line5 = $office->address3;
         $address->postcode = $office->postcode;
         $address->save();
         $migratedAddresses[$fullAddress] = $address;
         $office->addressId = $migratedAddresses[$fullAddress]->id;
         $office->save(false);
         continue;
     }
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:28,代码来源:m120923_123505_alter_table_office_add_addressID_and_migrate_data.php

示例5: 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

示例6: actionAdd

 public function actionAdd($id = 0)
 {
     if (!empty($id)) {
         $Insurance = Insurance::model()->findByPk($id);
         if (!Yii::app()->user->checkAccess('admin') && ((Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Insurance->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->insurance != '1' || $Insurance->user_id != Yii::app()->user->id) || Yii::app()->getUser()->getProfile()->company->active == '0')) {
             throw new CHttpException(403);
         }
         $Address = $Insurance->address;
         $ContentManager = null;
     } else {
         if (Yii::app()->user->getProfile()->content_manager == '0') {
             if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->insurance != '1' || Yii::app()->getUser()->getProfile()->company->active == '0')) {
                 throw new CHttpException(403);
             } elseif (!Yii::app()->getUser()->getProfile()->company->validate) {
                 $this->redirect('/complete');
             }
             $ContentManager = null;
         } else {
             $ContentManager = new ContentManager();
         }
         $Insurance = new Insurance();
         $Address = new Address();
         $Address->setscenario('insurance');
     }
     //if(isset($_POST['save'])) {
     if (!empty($_POST)) {
         if (!empty($Insurance->address)) {
             Address::model()->deleteByPk($Insurance->address->address_id);
         }
         if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
             $ContentManager->setAttributes($_POST['ContentManager'], false);
             $contentValid = $ContentManager->validate();
         } else {
             $contentValid = true;
         }
         $Insurance->setAttributes($_POST['Insurance'], false);
         $Address->setAttributes($_POST['Address'], false);
         $valid = $Address->validate();
         $valid = $Insurance->validate() && $valid && $contentValid;
         if ($valid) {
             if (Yii::app()->user->getProfile()->content_manager == '1' && $id == 0) {
                 $Insurance->user_id = User::createFakeUser($ContentManager);
                 $Insurance->contact_id = $Insurance->user_id;
             }
             $Address->save();
             $Insurance->address_id = $Address->address_id;
             $Insurance->save();
             $Insurance->autosearch();
             //                $this->redirect('/insurance');
             $this->render('insuranceaddsuccess', ['Insurance' => $Insurance, 'contacts' => User::getContact()]);
             exit;
         }
     }
     $this->render('add', ['Insurance' => $Insurance, 'Address' => $Address, 'contacts' => User::getContact(), 'ContentManager' => $ContentManager]);
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:55,代码来源:DefaultController.php

示例7: postCreateAddress

 public function postCreateAddress()
 {
     $address = new Address();
     $address->user_id = Auth::user()->id;
     $address->line_1 = Input::get('line1');
     $address->line_2 = Input::get('line2');
     $address->city = Input::get('city');
     $address->postcode = Input::get('postcode');
     $address->country = Input::get('country');
     $address->save();
     Session::flash('alert', 'Your address has been created.');
     return Redirect::to(route('my.addresses'));
 }
开发者ID:Fash1,项目名称:Fash1,代码行数:13,代码来源:MyController.php

示例8: run

 public function run()
 {
     DB::statement("TRUNCATE TABLE addresses");
     $cityId = City::select('id')->where('city', 'Da Nang')->first()->id;
     $address = array('306 - đường 2/9, Hai Chau', '225 Nguyễn Chí Thanh, Hai Chau', '123 Nguyen Van Linh, Hai Chau', '328 Hoang Dieu, Hai Chau', '423 Nguyen Huu Tho, Hai Chau');
     foreach ($address as $add) {
         $address = new Address();
         $address->city_id = $cityId;
         $address->address = $add;
         $address->created_at = new DateTime();
         $address->updated_at = new DateTime();
         $address->save();
     }
 }
开发者ID:EricBui0512,项目名称:FYP,代码行数:14,代码来源:AddressTableSeeder.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $address = new Address();
     $address->user_id = $user->id;
     $address->name = $request->name;
     $address->street = $request->street;
     $address->city = $request->city;
     $address->state = $request->state;
     $address->zip = $request->zip;
     $address->save();
     $request->session()->flash('status', 'Address information was successfully saved.');
     return Redirect::action('AddressController@index');
 }
开发者ID:samyerkes,项目名称:sweet.com,代码行数:20,代码来源:RecipeController.php

示例10: actionCreate

 public function actionCreate()
 {
     $model = new Address();
     if (isset($_POST['Address'])) {
         $model->setAttributes($_POST['Address']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->address_id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:schmunk42,项目名称:yii-sakila-crud,代码行数:15,代码来源:AddressController.php

示例11: checkCart

 /**
  * @param ShopgateCart $cart
  * @return array
  */
 public function checkCart(ShopgateCart $cart)
 {
     $this->_createCustomer($cart);
     if ($cart->getDeliveryAddress()) {
         if (!$cart->getDeliveryAddress()->getPhone()) {
             $cart->getDeliveryAddress()->setPhone($cart->getPhone());
         }
         $this->_deliveryAddress = $this->_createAddress($cart->getDeliveryAddress());
         $this->_deliveryAddress->id_customer = $this->getPlugin()->getContext()->customer->id;
         $this->_deliveryAddress->save();
         $this->getPlugin()->getContext()->cart->id_address_delivery = $this->_deliveryAddress->id;
         $this->getPlugin()->getContext()->cart->save();
     }
     if ($cart->getInvoiceAddress()) {
         if (!$cart->getInvoiceAddress()->getPhone()) {
             $cart->getInvoiceAddress()->setPhone($cart->getPhone());
         }
         $this->_invoiceAddress = $this->_createAddress($cart->getInvoiceAddress());
         $this->_deliveryAddress->id_customer = $this->getPlugin()->getContext()->customer->id;
         $this->_invoiceAddress->save();
         $this->getPlugin()->getContext()->cart->id_address_invoice = $this->_invoiceAddress->id;
         $this->getPlugin()->getContext()->cart->save();
     }
     /**
      * add selected carrier is given
      */
     if ($cart->getShippingType() == ShopgateShipping::DEFAULT_PLUGIN_API_KEY) {
         if (is_array(unserialize($cart->getShippingInfos()->getInternalShippingInfo()))) {
             $carrierInfo = unserialize($cart->getShippingInfos()->getInternalShippingInfo());
             $carrierId = isset($carrierInfo['carrierId']) ? $carrierInfo['carrierId'] : false;
             if ($carrierId) {
                 $this->getPlugin()->getContext()->cart->id_carrier = (int) $carrierId;
             }
         }
     }
     /**
      * don't change the direction
      */
     $result = array('items' => $this->_addItems($cart), 'external_coupons' => $this->_addCoupons($cart), 'currency' => $this->_getCurrency(), 'customer' => $this->_getCustomerGroups($cart), 'shipping_methods' => $this->_getCarriers(), 'payment_methods' => array());
     return $result;
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:45,代码来源:Json.php

示例12: doCreate

 /**
  * Adds new Address Record to database
  * 
  * @return  Redirect successfully redirects to home page
  */
 public function doCreate()
 {
     if (Auth::check()) {
         $address = Input::get('address');
         $address = Str::slug($address, '+');
         //Sends address through Google Maps Geocoding API, which converts it to Lat and Lng Values
         $response = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=AIzaSyBoaSu9IZTRrCkY1tTnMibgHg-uwB8aduk');
         $response = json_decode($response, true);
         $results = $response['results'];
         $address = new Address();
         $address->address = $results[0]['formatted_address'];
         $address->lng = $results[0]['geometry']['location']['lng'];
         $address->lat = $results[0]['geometry']['location']['lat'];
         $address->depth = Input::get('depth');
         $address->flow_rate = Input::get('flow_rate');
         $address->year_dug = Input::get('year_dug');
         $address->user_id = Auth::user()->id;
         $address->save();
         return Redirect::action('HomeController@index');
     }
 }
开发者ID:gdroel,项目名称:well-basically,代码行数:26,代码来源:HomeController.php

示例13: register

 public function register()
 {
     if ($this->validate()) {
         $address = new Address();
         $lines = explode("\n", $this->address);
         $postcode = '';
         if (count($lines) > 1) {
             $postcode = array_pop($lines);
         }
         for ($i = 0; $i < count($lines) && $i < 5; $i++) {
             $t = 'line' . ($i + 1);
             $address->{$t} = $lines[$i];
         }
         $address->postcode = strtoupper($postcode);
         $address->save();
         $client = new Client();
         $client->cli_fname = $this->name;
         $client->cli_sname = $this->surname;
         $client->cli_email = $this->email;
         $client->cli_branch = $this->branch;
         $client->cli_neg = 0;
         $client->cli_status = 'Active';
         $client->cli_salemin = $this->minPrice;
         $client->cli_salemax = $this->maxPrice;
         $client->cli_salebed = $this->bedrooms;
         $client->cli_sales = 'Yes';
         $client->cli_saleemail = 'Yes';
         $client->cli_salestatus = $this->currentPosition;
         $client->addressID = $address->id;
         if ($client->save(false)) {
             $telephone = new Telephone();
             $telephone->tel_type = 'Other';
             $telephone->tel_number = $this->telephone;
             $telephone->tel_cli = $client->cli_id;
             $telephone->tel_ord = 1;
             $telephone->save();
         }
         return true;
     }
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:40,代码来源:PublicClientRegisterForm.php

示例14: extractPostCodeForShippingRequest

 /**
  * process a search on postcode table store it to address entity
  * at the end return it for the api call
  *
  * @param $address_object
  *
  * @return string
  * @throws PrestaShopException
  */
 public function extractPostCodeForShippingRequest(Address $address_object)
 {
     $id_state = $address_object->id_state;
     $country_name = pSQL($address_object->country);
     $region_name = State::getNameById($id_state);
     $address = array('country' => $country_name, 'region' => $region_name, 'city' => $address_object->city, 'address' => $address_object->address1 . ($address_object->address2 ? ' ' . $address_object->address2 : ''), 'postcode' => $address_object->postcode);
     if ($this->isEnabledAutocompleteForPostcode($country_name)) {
         $dpd_postcode_address = new DpdGroupDpdPostcodeAddress();
         $dpd_postcode_address->loadDpdAddressByAddressId($address_object->id);
         $current_hash = $this->generateAddressHash($address);
         if ($dpd_postcode_address->id_address && $current_hash == $dpd_postcode_address->hash) {
             return $dpd_postcode_address->auto_postcode;
         }
         if (!$dpd_postcode_address->id_address || $current_hash != $dpd_postcode_address->hash) {
             $postcode_relevance = new stdClass();
             $post_code = $this->search($address, $postcode_relevance);
             $dpd_postcode_address->auto_postcode = $post_code;
             $dpd_postcode_address->id_address = $address_object->id;
             $dpd_postcode_address->hash = $current_hash;
             if ($this->isValid($post_code, $postcode_relevance)) {
                 $dpd_postcode_address->relevance = 1;
                 $address_object->postcode = $post_code;
                 $address_object->save();
             } else {
                 $dpd_postcode_address->relevance = 0;
             }
             if (!empty($dpd_postcode_address->dpd_postcode_id)) {
                 $dpd_postcode_address->id = $dpd_postcode_address->dpd_postcode_id;
             }
             $dpd_postcode_address->save();
         } else {
             return $dpd_postcode_address->auto_postcode;
         }
     } else {
         $post_code = $address_object->postcode;
     }
     return $post_code;
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:47,代码来源:PostcodeSearch.php

示例15: actionCreate

 public function actionCreate($id)
 {
     $model = new Address();
     //$this->performAjaxValidation($model);
     $model->comp_id = $id;
     if (isset($_POST['Address'])) {
         $model->attributes = $_POST['Address'];
         if ($model->save()) {
             if (Yii::app()->request->isAjaxRequest) {
                 echo CJSON::encode(array('status' => 1));
                 exit;
             } else {
                 $this->redirect(array('/company/view', 'id' => $id));
             }
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         Yii::app()->clientScript->scriptMap['jquery.js'] = false;
         Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
         echo CJSON::encode(array('status' => 0, 'div' => $this->renderPartial('/address/_form', array('model' => $model), true)));
         exit;
     }
 }
开发者ID:mehulsbhatt,项目名称:sale_purchase_tracking,代码行数:23,代码来源:AddressController.php


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