Beispiel #1
0
 public function postNewAddress()
 {
     \Log::info(json_encode(["tag" => "NEW_ADDRESS", "user_id" => Auth::user()->user_id, "address" => Request::input("address")]));
     $addressInput = Request::all()['address'];
     $validator = Validator::make($addressInput, ['first_name' => ['required'], 'last_name' => ['required'], 'street' => ['required'], 'city' => ['required'], 'state' => ['required'], 'zip' => ['required', 'required'], 'country_code' => ['required'], 'phone' => ['required']]);
     $addressInput['user_id'] = Auth::user()->user_id;
     if ($validator->fails()) {
         return error_popup("Address is not complete.");
     }
     $address = Store\Address::create($addressInput);
     $address->user()->associate(Auth::user());
     $address->save();
     $order = $this->userCart();
     $order->address()->associate($address);
     $order->save();
     return js_view("layout.ujs-reload");
 }
Beispiel #2
0
 public function postNewAddress()
 {
     \Log::info(json_encode(['tag' => 'NEW_ADDRESS', 'user_id' => Auth::user()->user_id, 'address' => Request::input('address')]));
     $addressInput = Request::all()['address'];
     $validator = Validator::make($addressInput, ['first_name' => ['required'], 'last_name' => ['required'], 'street' => ['required', 'mixture'], 'city' => ['required'], 'state' => ['required'], 'zip' => ['required', 'required'], 'country_code' => ['required'], 'phone' => ['required']]);
     $addressInput['user_id'] = Auth::user()->user_id;
     if ($validator->fails()) {
         return error_popup($validator->errors()->first());
     }
     $address = Store\Address::create($addressInput);
     $address->user()->associate(Auth::user());
     $address->save();
     $order = $this->userCart();
     $order->address()->associate($address);
     $order->save();
     return js_view('layout.ujs-reload');
 }