예제 #1
0
 public function changeAddress($data)
 {
     $customer = $this->getByToken();
     if ($customer) {
         $customer->shipping_same_as_invoice = $data['shipping_same_as_invoice'];
         $customer->save();
         unset($data['shipping_same_as_invoice']);
         unset($data['invoice_country_name']);
         unset($data['shipping_country_name']);
         $invoice_address = CustomerAddress::whereCustomerId($customer->id)->whereAddressKindId(config('shop.invoice_address_kind_id'))->first();
         foreach ($data as $name => $value) {
             if (substr($name, 0, 8) == 'invoice_') {
                 $name = substr($name, 8);
                 $invoice_address->{$name} = $value;
             }
         }
         $invoice_address->save();
         $shipping_address = CustomerAddress::whereCustomerId($customer->id)->whereAddressKindId(config('shop.shipping_address_kind_id'))->first();
         foreach ($data as $name => $value) {
             if (substr($name, 0, 9) == 'shipping_') {
                 $name = substr($name, 9);
                 $shipping_address->{$name} = $value;
             }
         }
         $shipping_address->save();
     }
     return $this->getByToken();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json = File::get(storage_path() . '/jsondata/customerAddress.json');
     $data = json_decode($json);
     foreach ($data as $obj) {
         CustomerAddress::create(array('id' => $obj->id, 'address' => $obj->address));
     }
 }
예제 #3
0
 public function show_sticker($id)
 {
     $delivery_history = DeliveryHistory::find($id);
     $input = unserialize($delivery_history->input);
     $quote = QuoteRequest::find($delivery_history->qr_id);
     $delivery_address = CustomerAddress::find($input['delivery_address']);
     // Create PDF
     $qtys = isset($input['number']) ? $input['number'] : '';
     $html = view('jobs.sticker', compact('input', 'quote', 'delivery_address', 'qtys'));
     $dompdf = PDF::loadHTML($html)->setPaper(array(0, 0, 422.37, 283.49));
     return $dompdf->stream();
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, $job)
 {
     $customer_address = CustomerAddress::find($id);
     $customer = $customer_address->customer_name;
     return view('customer_addresses.edit', compact('customer', 'job', 'customer_address'));
 }