本文整理汇总了PHP中app\Address::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::save方法的具体用法?PHP Address::save怎么用?PHP Address::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Address
的用法示例。
在下文中一共展示了Address::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$user = \Auth::user();
$v = \Validator::make($request->all(), $this->form_rules);
if ($v->fails()) {
return \Response::json(['success' => false, 'message' => trans('address.error_validation'), 'class' => 'alert alert-danger']);
}
$this->resetDefault();
$address = new Address();
$address->name_contact = $request->get('name_contact');
$address->line1 = $request->get('line1');
$address->line2 = $request->get('line2');
$address->city = $request->get('city');
$address->state = $request->get('state');
$address->zipcode = $request->get('zipcode');
$address->country = $request->get('country');
$address->phone = $request->get('phone');
$address->user_id = $user->id;
$address->default = '1';
$address->save();
if ($address) {
\Session::put('message', trans('address.success_save'));
\Session::save();
return \Response::json(['success' => true, 'callback' => '/user/address']);
} else {
return \Response::json(['success' => false, 'message' => trans('address.error_updating'), 'class' => 'alert alert-danger']);
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(BusinessRegRequest $request)
{
// dd($request->input('sub'));
$biz = new Biz();
$biz->name = $request->input('name');
$biz->contactname = $request->input('contactname');
$biz->email = $request->input('email');
$biz->website = $request->input('website');
$biz->phone1 = $request->input('phone1');
$biz->phone2 = $request->input('phone2');
$biz->user_id = \Auth::id();
$biz->save();
$add = new Address();
$add->street = $request->input('address');
$add->lga_id = $request->input('lga');
$add->state_id = $request->input('state');
$add->biz_id = $biz->id;
$add->save();
$category = $request->input('cats');
$biz->cats()->sync($category);
$subs = $request->input('sub');
$biz->subcats()->sync($subs);
$mon = BusinessHour::create(['day' => 'MON', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$tue = BusinessHour::create(['day' => 'TUE', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$wed = BusinessHour::create(['day' => 'WED', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$thu = BusinessHour::create(['day' => 'THU', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$fri = BusinessHour::create(['day' => 'FRI', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$sat = BusinessHour::create(['day' => 'SAT', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
$sun = BusinessHour::create(['day' => 'SUN', 'open_time' => 9, 'close_time' => 5, 'biz_id' => $biz->id]);
return redirect('/admin/biz')->withSuccess("The business '{$biz->name}' has been created.");
}
示例3: addAddress
public function addAddress($address_line_1, $address_line_2, $address_city, $address_postcode)
{
$address = new Address();
$address->line_1 = $address_line_1;
$address->line_2 = $address_line_2;
$address->city = $address_city;
$address->postcode = $address_postcode;
$address->save();
$this->addresses()->save($address);
}
示例4: 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();
Activity::log('Added a new address.');
$request->session()->flash('status', 'Address information was successfully saved.');
return Redirect::action('AddressController@index');
}
示例5: 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();
$addressRules = array('address_name' => 'required', 'name' => 'required', 'surname' => 'required', 'phone_number' => 'required|digits:11', 'city' => 'required', 'country' => 'required', 'distinct' => 'required', 'zip_code' => 'required', 'address_detail' => 'required');
$validator = Validator::make($request->all(), $addressRules);
if ($validator->fails()) {
return back()->withInput()->withErrors($validator);
} else {
$user = Auth::user();
$address = new Address();
$address->customer_id = $user->id;
$address->address_name = $request->input('address_name');
$address->name = $request->input('name');
$address->surname = $request->input('surname');
$address->phone_number = $request->input('phone_number');
$address->distinct = $request->input('distinct');
$address->city = $request->input('city');
$address->country = $request->input('country');
$address->address_detail = $request->input('address_detail');
$address->zip_code = $request->input('zip_code');
$address->save();
return redirect()->back()->with('success', ['Successful' => 'Adresiniz eklendi']);
}
}
示例6: addAddress
public function addAddress($address_1, $address_2, $town, $county, $postcode)
{
$address = new Address();
$address->line_1 = $address_1;
$address->line_2 = $address_2;
$address->city = $town;
$address->county = $county;
$address->postcode = $postcode;
$address->addressable_type = 'App\\Patient';
$address->addressable_id = $this->id;
$address->save();
$this->addHistoryItem("Patient Address Added", "This patient had an address added to their details.", Auth::user()->id, 4);
}
示例7: checkOutResume
/**
* Starts the checkout process.
*
* @param int $addressId The address id selected to be copied
* @return Response
*/
public function checkOutResume($addressId)
{
$user = \Auth::user();
$cart = Order::ofType('cart')->with('details')->where('user_id', $user->id)->first();
$cartDetail = OrderDetail::where('order_id', $cart->id)->get();
$address = Address::find($addressId);
$totalAmount = 0;
$totalItems = 0;
//Checks if the user selected an address that belongs to him/her
$userAddress = Address::where('user_id', $user->id)->where('id', $address->id)->first();
if ($userAddress) {
//Checks if the user has points for the cart price and the store has stock
$total_points = 0;
foreach ($cartDetail as $orderDetail) {
$product = Product::find($orderDetail->product_id);
$totalItems += $orderDetail->quantity;
$totalAmount += $orderDetail->quantity * $orderDetail->price;
if ($product->stock < $orderDetail->quantity) {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.insufficientStock'))));
}
}
//Checks if the user has points for the cart price
if ($user->current_points < $total_points && config('app.payment_method') == 'Points') {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.cart_view.insufficient_funds'))));
} else {
//Copies the Address to a new one and attaches it to the order or replaces the old one
$cartAddress = Address::find($cart->address_id);
if (!$cartAddress) {
//if the order does not has an address yet
$newAddress = new Address();
$newAddress->line1 = $address->line1;
$newAddress->line2 = $address->line2;
$newAddress->phone = $address->phone;
$newAddress->name_contact = $address->name_contact;
$newAddress->zipcode = $address->zipcode;
$newAddress->city = $address->city;
$newAddress->country = $address->country;
$newAddress->state = $address->state;
$newAddress->save();
$cart->address_id = $newAddress->id;
$cart->save();
$cartAddress = $newAddress;
} else {
//if the order needs to be updated
$cartAddress->line1 = $address->line1;
$cartAddress->line2 = $address->line2;
$cartAddress->phone = $address->phone;
$cartAddress->name_contact = $address->name_contact;
$cartAddress->zipcode = $address->zipcode;
$cartAddress->city = $address->city;
$cartAddress->country = $address->country;
$cartAddress->state = $address->state;
$cartAddress->save();
}
$panel = array('center' => ['width' => '12']);
//Sets the resume option to use the same view
$isResume = true;
$is_logged = true;
return view('orders.cart', compact('cart', 'user', 'panel', 'isResume', 'cartAddress', 'totalItems', 'totalAmount'));
}
} else {
return redirect()->route('orders.show_cart')->withErrors(array('main_error' => array(trans('store.errorOnAddress'))));
}
}
示例8: postUpdate
public function postUpdate(Request $request)
{
$arr_return = array(
'status' => 'error',
'message'=>''
);
$time =date('H:i:s', time());
$id_return_purchaseorder = session('current_returnpurchaseorder') !== null ? session('current_returnpurchaseorder') : 0;
if($id_return_purchaseorder){
$returnpurchaseorder = ReturnPurchaseorder::find($id_return_purchaseorder);
session(['current_returnpurchaseorder' => $returnpurchaseorder['id']]);
$time = date('H:i:s', strtotime($returnpurchaseorder->date));
}else{
$returnpurchaseorder = new ReturnPurchaseorder;
$returnpurchaseorder->date = date("Y-m-d H:i:s");
$returnpurchaseorder->created_by = \Auth::user()->id;
$returnpurchaseorder->save();
Log::create_log(\Auth::user()->id,'App\ReturnPurchaseorder','Tạo mới đơn hàng trả nhà cung cấp số '.$returnpurchaseorder->id);
session(['current_returnpurchaseorder' => $returnpurchaseorder->id]);
}
$log = '';
$old_company_id = $returnpurchaseorder->company_id;
if($returnpurchaseorder->status == 0){
$address = Address::where('module_id','=',$returnpurchaseorder->id)
->where('module_type','=','App\ReturnPurchaseorder')->first();
if(!$address){
$address = new Address;
}
if($request->has('company_id') && $returnpurchaseorder->company_id != $request->input('company_id')){
$old = Company::find($returnpurchaseorder->company_id);
if(!$old){
$old = (object) ['name'=>''];
}
$new = Company::find($request->input('company_id'));
$log .= 'công ty từ "'.$old->name.'" thành "'.$new->name.'" ';
}
if($returnpurchaseorder->company_id == $request->input('company_id')){
if($request->has('user_id') && $returnpurchaseorder->user_id != $request->input('user_id')){
$old = User::find($returnpurchaseorder->user_id);
if(!$old){
$old = (object) ['name'=>''];
}
$new = User::find($request->input('user_id'));
$log .= 'người liên hệ từ "'.$old->name.'" thành "'.$new->name.'" ';
}
$old_date=date("Y-m-d",strtotime($returnpurchaseorder->date));
$new_date = date("Y-m-d",strtotime($request->input('date')));
if($request->has('date') && $old_date != $new_date){
$log .= 'ngày từ "'.$old_date.'" thành "'.$new_date.'" ';
}
if($request->has('company_phone') && $returnpurchaseorder->company_phone != $request->input('company_phone')){
$log .= 'số điện thoại từ "'.$returnpurchaseorder->company_phone.'" thành "'.$request->input('company_phone').'" ';
}
if($request->has('company_email') && $returnpurchaseorder->company_email != $request->input('company_email')){
$log .= 'email từ "'.$returnpurchaseorder->company_email.'" thành "'.$request->input('company_email').'" ';
}
if($request->has('address') && $address->address != $request->input('address')){
$log .= 'địa chỉ từ "'.$address->address.'" thành "'.$request->input('address').'" ';
}
if($request->has('town_city') && $address->town_city != $request->input('town_city')){
$log .= 'quận huyện từ "'.$address->town_city.'" thành "'.$request->input('town_city').'" ';
}
if($request->has('province_id') && $address->province_id != $request->input('province_id')){
$old = Province::find($address->province_id);
$new = Province::find($request->input('province_id'));
if(!$old){
$old = (object) ['name'=>''];
}
$log .= 'tỉnh thành từ "'.$old->name.'" thành "'.$new->name.'" ';
}
if($request->has('country_id') && $address->country_id != $request->input('country_id')){
$old = Country::find($address->country_id);
$new = Country::find($request->input('country_id'));
if(!$old){
$old = (object) ['name'=>''];
}
$log .= 'quốc gia từ "'.$old->name.'" thành "'.$new->name.'" ';
}
}
$returnpurchaseorder->company_id = $request->has('company_id') ? $request->input('company_id') : 0;
$returnpurchaseorder->user_id = $request->has('user_id') ? $request->input('user_id') : 0;
$returnpurchaseorder->date = $request->has('date') ? date("Y-m-d H:i:s",strtotime($request->input('date').' '.$time)) : date("Y-m-d H:i:s");
$returnpurchaseorder->company_phone = $request->has('company_phone') ? $request->input('company_phone') : '';
$returnpurchaseorder->company_email = $request->has('company_email') ? $request->input('company_email') : '';
$address_id = isset($returnpurchaseorder->address_id) ? $returnpurchaseorder->address_id : 0;
$address->module_id = $returnpurchaseorder->id;
$address->module_type = 'App\\ReturnPurchaseorder';
$address->address = $request->has('address') ? $request->input('address') : '';
$address->town_city = $request->has('town_city') ? $request->input('town_city') : '';
$address->zip_postcode = $request->has('zip_postcode') ? $request->input('zip_postcode') : '';
$address->country_id = $request->has('country_id') ? $request->input('country_id') : 0;
//.........这里部分代码省略.........
示例9: addresses
public function addresses($num, $contact_id)
{
for ($i = 0; $i < $num; $i++) {
$item = new Address();
$item->city = $this->faker->city;
$item->state = $this->faker->state;
$item->zip = $this->faker->postcode;
$item->street = $this->faker->streetName;
$item->building = $this->faker->buildingNumber;
$item->apartment = $this->faker->numberBetween(0, 200);
$item->full_string = $this->faker->address;
$item->lat = $this->faker->latitude;
$item->lng = $this->faker->longitude;
$item->country = $this->faker->country;
$item->contact_id = $contact_id;
$item->timezone = $this->faker->timezone;
$item->save();
$this->phones($this->faker->numberBetween(1, 2), $item->id);
}
}
示例10: anyUpdate
public function anyUpdate(Request $request)
{
$arr_return = array('status' => 'error');
$id = session('current_company') !== null ? session('current_company') : 0;
$address_id = session('current_address') !== null ? session('current_address') : 0;
if ($id) {
$company = Company::find($id);
$address = Address::getAddressByCompanyId($id);
session(['current_company' => $company['id'], 'current_address' => $address['id']]);
} else {
$company = Company::get()->last();
//$address = Address::get()->last();
if ($company && $address) {
session(['current_company' => $company->id, 'current_address' => $address->id]);
} else {
$company = new Company();
$company->save();
$address = new Address();
$address->save();
session(['current_company' => $company->id, 'current_address' => $address->id]);
}
}
$company->name = $request->has('name') ? $request->input('name') : '';
$company->phone = $request->has('phone') ? $request->input('phone') : '';
$company->company_type_id = $request->has('company_type') ? $request->input('company_type') : 0;
$company->fax = $request->has('fax') ? $request->input('fax') : '';
$company->email = $request->has('email') ? $request->input('email') : '';
$company->web = $request->has('web') ? $request->input('web') : '';
$company->is_customer = $request->has('is_customer') ? 1 : 0;
$company->is_distribute = $request->has('is_distribute') ? 1 : 0;
$address->address = $request->has('address') ? $request->input('address') : '';
$address->town_city = $request->has('town_city') ? $request->input('town_city') : '';
$address->province_id = $request->has('province_id') ? $request->input('province_id') : 0;
$address->country_id = $request->has('country_id') ? $request->input('country_id') : 0;
if ($company->save()) {
$arr_return['status'] = 'success';
$arr_return['name'] = $company->name;
} else {
$arr_return['message'] = 'Saving fail';
}
if ($address->save()) {
$arr_return['status'] = 'success';
$arr_return['name'] = $address->name;
} else {
$arr_return['message'] = 'Saving fail';
}
return $arr_return;
}
示例11: createLead
public function createLead(Request $request)
{
$lead = new Lead();
$lead->name = $request->name;
$lead->activity_setting = $request->setting;
if ($request->next_action) {
$lead->next_action = Carbon::createFromFormat('m/d/Y g:i A', $request->next_action)->toDateTimeString();
} else {
$lead->next_action = null;
}
$lead->active = 1;
$lead->progress = 0;
$lead->level = 0;
$lead->save();
$entity = new Entity();
$entity->name = $request->entity['name'];
$entity->type = $request->entity['type'];
$entity->save();
$lead->entity_id = $entity->id;
$lead->save();
$user = User::find($request->userId);
$user->leads()->attach($lead);
$account = Account::find($user->account_id);
$account->entities()->attach($entity);
foreach ($request->entity['entity_data'] as $eData) {
$entityData = new EntityData();
$entityData->key = $eData['key'];
$entityData->value = $eData['value'];
$entityData->name = $eData['name'];
$entityData->entity_id = $entity->id;
$entityData->type = strtolower($eData['type']);
//TODO
$entityData->save();
}
foreach ($request->entity['contacts'] as $cntct) {
$contact = new Contact();
$contact->email = $cntct['email'];
$contact->first_name = $cntct['first_name'];
$contact->last_name = $cntct['last_name'];
$contact->title = $cntct['title'];
$contact->type = $cntct['type'];
$contact->entity_id = $entity->id;
$contact->save();
foreach ($cntct['addresses'] as $adr) {
$address = new Address();
$address->name = $adr['name'];
$address->full_string = $adr['full_string'];
$address->contact_id = $contact->id;
$address->save();
foreach ($adr['phones'] as $ph) {
$phone = new Phone();
$phone->number = $ph['number'];
$phone->available_from = $ph['available_from'];
$phone->available_to = $ph['available_to'];
$phone->type = $ph['type'];
$phone->address_id = $address->id;
$phone->save();
}
}
}
$activity = new Activity();
$activity->lead_id = $lead->id;
$activity->user_id = $user->id;
$activity->type = 'info';
$activity->status = 'done';
$activity->name = 'Created';
$activity->visible = 1;
$activity->note = $request->note;
$activity->schedule_time = Carbon::now()->toDateTimeString();
$activity->save();
}
示例12: addAddress
public function addAddress($data)
{
if ($this->addresses()->count() > 0) {
$address = $this->addresses()->first();
} else {
$address = new Address();
}
$address->line_1 = $data['line_1'];
$address->line_2 = $data['line_2'];
$address->city = $data['city'];
$address->county = $data['county'];
$address->postcode = $data['postcode'];
$address->addressable_id = $this->id;
$address->addressable_type = 'App\\User';
$address->save();
}
示例13: postCreateSenderAddress
public function postCreateSenderAddress()
{
$address = new Address();
if (Request::ajax()) {
$data = Input::all();
$address->user_id = Auth::user()->id;
$address->name = $data['name'];
$address->address_line_1 = $data['address_line_1'];
$address->address_line_2 = $data['address_line_2'];
$address->address_line_3 = $data['address_line_3'];
$address->postcode = $data['postcode'];
$address->is_sender = true;
$address->save();
}
return "OK";
}