public function postBook() { $response = null; $Bill = null; $spa_id = Input::get('spaName'); $outlet_id = Input::get('spaLocation'); $service_id = Input::get('serviceName'); $apptDate = Input::get('apptDate'); $apptTime = Input::get('timeSlot'); if (!empty($spa_id) && !empty($outlet_id) && !empty($service_id) && !empty($apptDate)) { $apptDateTime = strtotime($apptDate . " " . $apptTime); $service = Service::find($service_id); $response = array("retailerName" => Retailer::find($spa_id)->name, "outletName" => Outlet::find($outlet_id)->name, "serviceName" => $service->name . " (" . $service->time_operate . " mins)", "apptDateTime" => $apptDateTime, "price" => $service->price); if (!Auth::user()) { return View::make('site/user/book', compact('response', 'Bill')); } $deal = Deal::where('service_id', '=', $service_id)->where('deal_type', '=', 'Service')->first(); if ($deal == null) { $deal = new Deal(); $deal->service_id = $service_id; $deal->deal_type = 'Service'; $deal->title = $service->name; $deal->amount = $service->price; $deal->discount = 0; $deal->special_request = ""; $deal->status = "active"; $deal->save(); } $Bill = new DealTransaction(); $Bill->deal_id = $deal->id; $Bill->consumer_id = Auth::user()->id; $Bill->consumer_email = Auth::user()->email; $Bill->qty = 1; $Bill->amount = $service->price; $Bill->total = $service->price; $Bill->save(); return View::make('site/user/book', compact('response', 'Bill')); } return Redirect::to('/'); }
/** * Returns all the blog posts. * * @return View */ public function createBill() { // Validate the inputs $validator = Validator::make(Input::all(), DealTransaction::$rules); $detail = $this->deal->detail(Input::get('deal_id')); if (!Auth::user()) { return Redirect::to('purchase/' . $detail->id)->with('message', 'Login please!'); } if ($validator->passes()) { $data = Input::except('_token'); $bill = new DealTransaction(); $bill->deal_id = $data['deal_id']; $bill->consumer_id = Auth::user()->id; $bill->consumer_email = Auth::user()->email; $bill->qty = $data['qty']; $bill->phone_number = $data['phone_number']; $bill->amount = $data['amount']; $bill->total = $data['amount'] * $data['qty']; if ($bill->save()) { // var_dump($Bill->id);die; // Redirect to the new country page return View::make('site.purchase.pay', compact('bill')); } return Redirect::to('purchase/' . $detail->id)->withInput()->withErrors($validator); } // Show the page }