本文整理汇总了PHP中Address::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::create方法的具体用法?PHP Address::create怎么用?PHP Address::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
DB::table('addresses')->delete();
Address::create(['address' => 'mtqSqRAGB7EuPtgCwvMtX74S2tvTapDWD6', 'user_id' => 1]);
Address::create(['address' => 'n21cjTZa59QcMBXFvoKx2WoRotBV9mErnJ', 'user_id' => 1]);
Address::create(['address' => 'mxKRETCDzCuLVLiw9MieJb8xFi1WhkQ9wY', 'user_id' => 1]);
}
示例2: saveItem
/**
* (non-PHPdoc)
* @see DetailsPageAbstract::saveItem()
*/
public function saveItem($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
if (!isset($param->CallbackParameter->id)) {
throw new Exception('Invalid supplier ID passed in!');
}
$supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id);
if (!$supplier instanceof Supplier) {
throw new Exception('Invalid supplier passed in!');
}
$contactName = trim($param->CallbackParameter->address->contactName);
$contactNo = trim($param->CallbackParameter->address->contactNo);
$street = trim($param->CallbackParameter->address->street);
$city = trim($param->CallbackParameter->address->city);
$region = trim($param->CallbackParameter->address->region);
$postCode = trim($param->CallbackParameter->address->postCode);
$country = trim($param->CallbackParameter->address->country);
$address = $supplier->getAddress();
$supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save();
$results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : '');
$results['item'] = $supplier->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage() . $ex->getTraceAsString();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例3: run
public function run()
{
// $faker->seed(1234);
for ($x = 0; $x < 1000; $x++) {
Address::create(array('address' => '1688 Los Berros Rd', 'lng' => rand(-120, 120), 'lat' => rand(-120, 120), 'depth' => rand(0, 100), 'flow_rate' => rand(0, 100), 'year_dug' => rand(0, 200), 'user_id' => rand(0, 1000)));
}
$this->command->info('Person table seeded using Faker ...');
}
示例4: store
/**
* Store a newly created address in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Address::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
Address::create($data);
return Redirect::route('addresses.index');
}
示例5: addAddress
public function addAddress($params, $default = false)
{
$address = Address::create($params);
$this->addresses()->save($address);
if ($default) {
$this->address()->associate($address);
$this->save();
}
}
示例6: run
public function run()
{
// not to delete in production just in case lol
if (App::environment('production')) {
DB::table('addresses')->delete();
}
Address::create(['address' => 'mtqSqRAGB7EuPtgCwvMtX74S2tvTapDWD6', 'user_id' => 1]);
Address::create(['address' => 'n21cjTZa59QcMBXFvoKx2WoRotBV9mErnJ', 'user_id' => 1]);
Address::create(['address' => 'mxKRETCDzCuLVLiw9MieJb8xFi1WhkQ9wY', 'user_id' => 1]);
}
示例7: getAddress
/**
* Get location of user
*
* @param Address $address location
*/
public function getAddress()
{
$address = null;
if ($data = $this->getLocationData()) {
$address = Address::create();
$address->update($data);
$address->ID = 0;
//ensure not in db
}
return $address;
}
示例8: run
public function run()
{
$customers = array(array('last_name' => 'Jones', 'first_name' => 'Tim', 'telephone1' => '(918) 555 1212', 'email' => 'tdjones@example.com', 'password' => Hash::make('password'), 'admin_ind' => TRUE), array('last_name' => 'User', 'first_name' => 'Joe', 'telephone1' => '(918) 555 1212', 'email' => 'joe@example.com', 'password' => Hash::make('password'), 'admin_ind' => FALSE), array('last_name' => 'vincent', 'first_name' => 'jan michael', 'telephone1' => '(918) 555 7890', 'email' => 'jmvincent@example.com', 'password' => Hash::make('password'), 'admin_ind' => FALSE));
$addresses = array(array('addr1' => '123 My Street', 'city' => 'Owasso', 'state' => 'OK', 'postal_code' => '74055', 'country' => 'USA'), array('addr1' => '123 Joe\'s Street', 'city' => 'Owasso', 'state' => 'OK', 'postal_code' => '74055', 'country' => 'USA'), array('addr1' => '456 Oak Street', 'city' => 'Tulsa', 'state' => 'OK', 'postal_code' => '74102', 'country' => 'USA'), array('addr1' => '888 Yellow Lane', 'addr2' => 'c/o Sacramento Church of Christ', 'city' => 'Sacramento', 'state' => 'CA', 'postal_code' => '99999', 'country' => 'USA'));
foreach ($customers as $customer) {
$customer['password_confirmation'] = $customer['password'];
$newcust = Customer::create($customer);
//var_dump($customer);
// Choose a random address from the list and insert it for the new customer.
$address = $addresses[mt_rand(0, count($addresses) - 1)];
$address['customer_id'] = $newcust->id;
Address::create($address);
}
}
示例9: testRequiredFields
public function testRequiredFields()
{
// create address instance that lacks some required fields (Address)
$address = Address::create(array('Country' => 'NZ', 'State' => 'Wellington', 'City' => 'TeAro'));
$writeFailed = false;
try {
$address->write();
} catch (Exception $ex) {
$writeFailed = true;
}
$this->assertTrue($writeFailed, "Address should not be writable, since it doesn't contain all required fields");
// Create an Address that satisfies the baseline required fields, but not the ones that were added via subclass.
$address = ExtendedTestAddress::create(array('Country' => 'NZ', 'State' => 'Wellington', 'City' => 'TeAro', 'Address' => '23 Blah Street'));
$writeFailed = false;
try {
$address->write();
} catch (Exception $ex) {
$writeFailed = true;
}
$this->assertTrue($writeFailed, "Address should not be writable, since it doesn't contain required fields added via subclass");
}
示例10: create
/**
* Factory method to create a Contact object from an array
* @param array $props - Associative array of initial properties to set
* @return Contact
*/
public static function create(array $props)
{
$contact = new Contact();
$contact->id = parent::getValue($props, "id");
$contact->status = parent::getValue($props, "status");
$contact->first_name = parent::getValue($props, "first_name");
$contact->middle_name = parent::getValue($props, "middle_name");
$contact->last_name = parent::getValue($props, "last_name");
$contact->confirmed = parent::getValue($props, "confirmed");
$contact->source = parent::getValue($props, "source");
foreach ($props['email_addresses'] as $email_address) {
$contact->email_addresses[] = EmailAddress::create($email_address);
}
$contact->prefix_name = parent::getValue($props, "prefix_name");
$contact->job_title = parent::getValue($props, "job_title");
foreach ($props['addresses'] as $address) {
$contact->addresses[] = Address::create($address);
}
foreach ($props['notes'] as $note) {
$contact->notes[] = Note::create($note);
}
$contact->company_name = parent::getValue($props, "company_name");
$contact->home_phone = parent::getValue($props, "home_phone");
$contact->work_phone = parent::getValue($props, "work_phone");
$contact->cell_phone = parent::getValue($props, "cell_phone");
$contact->fax = parent::getValue($props, "fax");
foreach ($props['custom_fields'] as $custom_field) {
$contact->custom_fields[] = CustomField::create($custom_field);
}
foreach ($props['lists'] as $contact_list) {
$contact->lists[] = ContactList::create($contact_list);
}
$contact->source_details = parent::getValue($props, "source_details");
return $contact;
}
示例11: saveOrder
/**
* saveOrder
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*
*/
public function saveOrder($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$customer = Customer::get(trim($param->CallbackParameter->customer->id));
if (!$customer instanceof Customer) {
throw new Exception('Invalid Customer passed in!');
}
if (!isset($param->CallbackParameter->applyTo) || ($applyTo = trim($param->CallbackParameter->applyTo)) === '' || !in_array($applyTo, CreditNote::getApplyToTypes())) {
throw new Exception('Invalid Apply To passed in!');
}
if (isset($param->CallbackParameter->creditNoteId) && ($creditNote = CreditNote::get(trim($param->CallbackParameter->creditNoteId))) instanceof CreditNote) {
$creditNote = $creditNote;
} else {
if (isset($param->CallbackParameter->orderId) && ($order = Order::get(trim($param->CallbackParameter->orderId))) instanceof Order) {
$creditNote = CreditNote::createFromOrder($order, $customer, trim($param->CallbackParameter->description));
} else {
$creditNote = CreditNote::create($customer, trim($param->CallbackParameter->description));
}
}
$creditNote->setShippingValue(isset($param->CallbackParameter->totalShippingCost) ? StringUtilsAbstract::getValueFromCurrency($param->CallbackParameter->totalShippingCost) : 0);
if (isset($param->CallbackParameter->shippingAddr)) {
$shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo);
$customer->setShippingAddress($shippAddress);
}
$printItAfterSave = false;
if (isset($param->CallbackParameter->printIt)) {
$printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false;
}
if (isset($param->CallbackParameter->comments)) {
$comments = trim($param->CallbackParameter->comments);
$creditNote->addComment($comments, Comments::TYPE_SALES);
}
$totalPaymentDue = $creditNote->getShippingValue();
$hasShipped = $creditNote->getOrder() instanceof Order && Shippment::countByCriteria('orderId = ?', array($creditNote->getOrder()->getId())) > 0;
$creditNoteItemsMap = array();
foreach ($param->CallbackParameter->items as $item) {
if (!($product = Product::get(trim($item->product->id))) instanceof Product) {
throw new Exception('Invalid Product passed in!');
}
$unitPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice));
$qtyOrdered = trim($item->qtyOrdered);
$totalPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->totalPrice));
$itemDescription = trim($item->itemDescription);
$active = trim($item->valid);
$totalPaymentDue += $totalPrice;
if (is_numeric($item->creditNoteItemId) && !CreditNoteItem::get(trim($item->creditNoteItemId)) instanceof CreditNoteItem) {
throw new Exception('Invalid Credit Note Item passed in');
}
$unitCost = $product->getUnitCost();
$orderItem = null;
if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) {
$unitCost = $orderItem->getUnitCost();
}
$creditNoteItem = is_numeric($item->creditNoteItemId) ? CreditNoteItem::get(trim($item->creditNoteItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setUnitPrice($unitPrice)->setItemDescription($itemDescription)->setUnitCost($unitCost)->setTotalPrice($totalPrice)->save() : ($orderItem instanceof OrderItem ? CreditNoteItem::createFromOrderItem($creditNote, $orderItem, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice) : CreditNoteItem::create($creditNote, $product, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice));
if (intval($creditNoteItem->getActive()) === 1) {
if (!isset($creditNoteItemsMap[$product->getId()])) {
$creditNoteItemsMap[$product->getId()] = 0;
}
$creditNoteItemsMap[$product->getId()] += $qtyOrdered;
}
//if we are not creating from a order, or there are shippments for this order then
if (!$creditNote->getOrder() instanceof Order || $hasShipped === true) {
switch (trim($item->stockData)) {
case 'StockOnHand':
$product->returnedIntoSOH($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
break;
case 'StockOnRMA':
$product->returnedIntoRMA($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
break;
default:
throw new Exception('System Error: NO where to transfer the stock: ' . trim($item->stockData) . ' for product(SKU=' . $product->getSku() . ').');
}
} else {
//revert all the shipped stock
foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isShipped = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
$orderItem->setIsShipped(false)->save();
}
//revert all the picked stock
foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isPicked = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
$orderItem->setIsPicked(false)->save();
}
}
}
if (($paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId))) instanceof PaymentMethod) {
$creditNote->setTotalPaid($totalPaidAmount = $param->CallbackParameter->totalPaidAmount)->addPayment($paymentMethod, $totalPaidAmount);
}
$creditNote->setTotalValue($totalPaymentDue)->setApplyTo($applyTo)->save();
//if need to check half credited orders
if ($creditNote->getOrder() instanceof Order && $hasShipped === false) {
//.........这里部分代码省略.........
示例12:
$address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:'');
$address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:'');
$address->address = $_POST["address"];
$address->cp = $_POST["zipcode"];
$address->ville = $_POST["town"];
$address->pays_id = $_POST["pays_id"];
$address->tel = $_POST["tel"];
$address->fax = $_POST["fax"];
$address->note = $_POST["note"];
if ($_POST["action"] == 'add')
{
$socid = $_POST["socid"];
$origin = $_POST["origin"];
$originid = $_POST["originid"];
$result = $address->create($socid, $user);
if ($result >= 0)
{
if ($origin == commande)
{
Header("Location: ../commande/fiche.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit;
}
elseif ($origin == propal)
{
Header("Location: ../comm/propal.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
exit;
}
else
{
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
die(Input::get('tab_index'));
$input = Input::all();
// STEP 1 : validate data (pendding)
$validator = Validator::make($input, Customer::$rules);
if (!$validator->passes()) {
return Redirect::back()->withErrors($validator)->withInput();
}
// STEP 2 : build objects
// Customer Stuff
$customerData = array();
$customerData['name_fiscal'] = $input['name_fiscal'];
// $customerData['name_commercial'] = $input['name_commercial'];
// $customerData['firstname'] = $input['firstname'];
// $customerData['lastname'] = $input['lastname'];
// $customerData['email'] = $input['email'];
$customerData['website'] = Input::get('website', '');
$customerData['identification'] = Input::get('identification', '');
// $customerData['phone'] = $input['phone'];
// $customerData['phone_mobile'] = $input['phone_mobile'];
// $customerData['fax'] = $input['fax'];
$customerData['outstanding_amount_allowed'] = Input::get('outstanding_amount_allowed', Configuration::get('DEF_OUTSTANDING_AMOUNT'));
$customerData['outstanding_amount'] = 0;
$customerData['unresolved_amount'] = 0;
$customerData['notes'] = Input::get('notes', '');
$customerData['accept_einvoice'] = Input::get('accept_einvoice', 0);
$customerData['accept_einvoice'] = intval($customerData['accept_einvoice']) > 0 ? 1 : 0;
$customerData['blocked'] = 0;
$customerData['active'] = Input::get('activce', 1);
$customerData['active'] = intval($customerData['active']) > 0 ? 1 : 0;
// Customer Relations!
$customerData['salesrep_id'] = 0;
$customerData['currency_id'] = 0;
$customerData['customer_group_id'] = 0;
$customerData['payment_method_id'] = 0;
$customerData['sequence_id'] = 0;
$customerData['carrier_id'] = 0;
$customerData['price_list_id'] = 0;
$customerData['direct_debit_account_id'] = 0;
$customerData['invoicing_address_id'] = 0;
$customerData['shipping_address_id'] = 0;
// Addresses Stuff
$addressInvData = array();
$addressInvData['alias'] = 'Dirección Principal';
$addressInvData['model_name'] = 'Customer';
$addressInvData['name_commercial'] = Input::get('name_commercial', '');
$addressInvData['address1'] = Input::get('address1', '');
$addressInvData['address2'] = Input::get('address2', '');
$addressInvData['postcode'] = Input::get('postcode', '');
$addressInvData['city'] = Input::get('city', '');
$addressInvData['state'] = Input::get('state', '');
$addressInvData['country'] = Input::get('country', Configuration::get('DEF_COUNTRY_NAME'));
$addressInvData['firstname'] = Input::get('firstname', '');
$addressInvData['lastname'] = Input::get('lastname', '');
$addressInvData['email'] = Input::get('email', '');
$addressInvData['phone'] = Input::get('phone', '');
$addressInvData['phone_mobile'] = Input::get('phone_mobile', '');
$addressInvData['fax'] = Input::get('fax', '');
$addressInvData['notes'] = '';
$addressInvData['active'] = 1;
$addressInvData['latitude'] = 0;
$addressInvData['longitude'] = 0;
// Address Relations!
$addressInvData['owner_id'] = 0;
$addressInvData['state_id'] = 0;
$addressInvData['country_id'] = 0;
$addressShipData = array();
// $addressShipData[''] = $input['ship_address_'];
$customer = Customer::create($customerData);
$addressInv = Address::create($addressInvData);
$addressInv->Customer()->associate($customer);
$customer->addresses()->save($addressInv);
$customer->invoicing_address_id = $addressInv->id;
$customer->shipping_address_id = $addressInv->id;
$customer->save();
// $customer->touch();
// See: http://stackoverflow.com/questions/16740973/one-to-many-relationship-inserts-2-records-into-table
// Kind of different...
/*
return Redirect::route('customers.create')
->withInput()
->with('message_error', 'Esta txuta!');
*/
// return Redirect::to('customers/' . $customer->id . '/edit')
return Redirect::to('customers')->with('success', 'El Cliente se ha creado correctamente.');
// return Redirect::route('customers.create')
// ->with('message_error', 'Esta txuta!');
/*
$v = Validator::make($input, Customer::$rules);
if ($v->passes())
{
$this->customer->create($input);
//.........这里部分代码省略.........
示例14: update
/**
* Update the specified outlet in storage.
*
* @param int $id
* @return Response
*/
public function update($outlet)
{
$data = Input::except('summary');
$description = Input::only('full_description', 'summary');
$validator = Validator::make($data = Input::all(), Outlet::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
if ($outlet->description_id) {
$desc = OutletDescription::where('id', $outlet->description_id)->update($description);
} else {
$desc = OutletDescription::create($description);
$data['description_id'] = $desc->id;
}
$addressData = array('city_id' => $data['city_id'], 'address' => $data['address']);
if ($outlet->address_id) {
$address = Address::where('id', $outlet->address_id)->update($addressData);
} else {
$address = Address::create($addressData);
$data['address_id'] = $address->id;
}
unset($data['full_description']);
unset($data['address']);
$data['status'] = 'active';
if ($outlet->update($data)) {
return Redirect::to('outlet')->with('success', Lang::get('site/outlets/messages.update.success'));
}
return Redirect::route('outlet.edit')->with('error', Lang::get('site/outlets/messages.update.error'));
}
示例15: saveaddress
public function saveaddress($data, $form)
{
$member = $this->getMember();
$address = Address::create();
$form->saveInto($address);
$address->MemberID = $member->ID;
// Add value for Country if missing (due readonly field in form)
if ($country = SiteConfig::current_site_config()->getSingleCountry()) {
$address->Country = $country;
}
$address->write();
if (!$member->DefaultShippingAddressID) {
$member->DefaultShippingAddressID = $address->ID;
$member->write();
}
if (!$member->DefaultBillingAddressID) {
$member->DefaultBillingAddressID = $address->ID;
$member->write();
}
$form->sessionMessage(_t("CreateAddressForm.AddressSaved", "Your address has been saved"), "good");
$this->extend('updateCreateAddressFormResponse', $form, $data, $response);
return $response ?: $this->redirect($this->Link('addressbook'));
}