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); }
public function postSwitchActive() { if (Input::has('id')) { echo ProductOrder::switchShow(Input::get('id')); } else { echo "0"; } }