/** * @param CustomerRepository $customerRepository * @return \Illuminate\Http\RedirectResponse */ public function save(CustomerRepository $customerRepository) { $customer = $customerRepository->find(); $data = Request::all(); $data['id'] = $data['addressId']; $customer->addAddress(new Address($data)); $customerRepository->save($customer); return Redirect::route('vendirun.customer.account'); }
/** * Process Contact form * @param IlRequest $request * @param CustomerRepository $customerRepository * @return mixed */ public function processContactForm(IlRequest $request, CustomerRepository $customerRepository) { $this->validate($request, ['email' => 'required']); // we will always make a new customer on contact forms, in case the form values are wildly different from the logged in user's details $customerFactory = new CustomerFactory(); $customer = $customerFactory->make(null, Request::get('fullname', null), Request::get('email')); $customer->setPrimaryTelephone(Request::get('telephone', null)); $customerRepository->save($customer); if (Request::has('propertyId')) { VendirunApi::makeRequest('property/addToFavourite', ['customer_id' => $customer->getId(), 'property_id' => Request::get('propertyId')]); Cache::forget('favourites-' . Session::get('token')); } $note = ''; if (Request::has('property')) { $note .= "<strong>Property Name: " . Request::get('property') . '</strong><br>'; } if (Request::has('product')) { $note .= "<strong>Product Name: " . Request::get('product') . '</strong><br>'; } if (Request::has('message')) { $note .= nl2br(Request::get('message', '')); } if ($note) { VendirunApi::makeRequest('customer/addNote', ['customer_id' => $customer->getId(), 'note' => $note]); } $formId = Request::get('formId', 'Website Form'); VendirunApi::makeRequest('customer/registerFormCompletion', ['customer_id' => $customer->getId(), 'new_customer' => 1, 'data' => json_encode(Request::all()), 'form_id' => $formId]); switch ($formId) { case 'Newsletter Signup': Session::flash('vendirun-alert-success', trans('vendirun::forms.newsletterThanks')); break; default: Session::flash('vendirun-alert-success', trans('vendirun::forms.contactThanks')); } return Redirect::back(); }