public function postOrder($lang = 'id') { $url_source = Input::get('url_source'); if ($url_source) { $url_source = URL::to('/'); } $promo = Promo::Active()->first(); if (!$promo) { return Redirect::to($url_source); } $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required')); if ($validator->fails()) { return Redirect::to($url_source); } $contact = new PromoOrder(); $contact->name = Input::get('name'); $contact->email = Input::get('email'); $contact->promo_id = Input::get('promo_id'); $contact->save(); $email = Notification::sendEmailGetPromo($contact); if (!$email) { Log::error('Failed sending Promo Order email with reference ID : ' . $contact->id); } if (!$contact->id) { Log::error('Failed updating database promo order from : ' . $contact->name . ' - ' . $contact->email); } restrictPromoPopup(); return Redirect::back(); }
public function postBuy($lang = 'id') { $product = Product::find(Input::get('product_id')); if (!$product) { return Redirect::route('site.product', array('lang' => $lang)); } $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email'), 'Phone' => Input::get('phone'), 'Address' => Input::get('address')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required', 'Phone' => 'required', 'Address' => 'required')); if ($validator->fails()) { return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->withErrors($validator->errors()); } $contact = new ProductOrder(); $contact->name = Input::get('name'); $contact->email = Input::get('email'); $contact->phone = Input::get('phone'); $contact->address = Input::get('address'); $contact->message = Input::get('message'); $contact->product_id = $product->id; $contact->product_name = $product->name_id; if ($lang == 'en') { $contact->product_name = $product->name_en; } $contact->price = $product->price; $contact->save(); $email = Notification::sendEmailBuyProduct($contact); if (!$email) { Log::error('Failed sending Product Purchase email with reference ID : ' . $contact->id); } if (!$contact->id) { $errorMessage = "Proses gagal, coba beberapa saat lagi"; if ($lang == 'en') { $errorMessage = "Process failed, please try again later"; } return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->with('error_message', $errorMessage); } $successMessage = "Pesanan Anda telah kami terima, kami akan segera menghubungi anda untuk proses konfirmasi"; if ($lang == 'en') { $successMessage = "We have received your order, we will contact you soon for confirmation"; } return Redirect::route('site.product', array('lang' => $lang))->with('success', $successMessage); }