public static function tranDetail($id) { $tran = DealTransaction::select(array('deal_transactions.*', 'deals.title', 'deals.id as deal_id', 'deals.discount', 'images.thumbnail_path'))->leftJoin('deals', 'deals.id', '=', 'deal_transactions.deal_id')->leftJoin('services', 'services.id', '=', 'deals.service_id')->leftJoin('images', function ($join) { $join->on('images.ref_id', '=', 'services.id')->where('images.image_type', '=', 'service'); })->where('deal_transactions.id', $id)->first(); return $tran; }
public static function destroy($outlets, $id = null) { $serviceIds = $dealIds = $outletIds = []; if (!empty($outlets)) { if ($id) { array_push($outletIds, $id); } else { foreach ($outlets as $key => $outlet) { array_push($outletIds, $outlet->id); } } $services = Service::whereIn('outlet_id', $outletIds)->get(); foreach ($services as $key => $service) { array_push($serviceIds, $service->id); } // delete deal $deals = Deal::whereIn('service_id', $serviceIds)->get(); foreach ($deals as $key => $deal) { array_push($dealIds, $deal->id); } // delete deal transaction DealTransaction::whereIn('deal_id', $dealIds)->delete(); Deal::whereIn('id', $dealIds)->delete(); Service::whereIn('id', $serviceIds)->delete(); Outlet::whereIn('id', $outletIds)->delete(); } }
public function getChartDay() { $data = DealTransaction::chartDay(); $days = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); $tran = $charts = array(); foreach ($days as $day) { $count = 0; $dayConvert = date('m-d-Y', strtotime("-{$day} day")); foreach ($data as $key => $value) { // var_dump($value);die; if ($dayConvert === $value->created_at) { $count = $value->count; } } $tran = array('category' => $dayConvert, 'value' => $count); array_push($charts, $tran); } // foreach ($data as $key => $value) { // $day = // var_dump($value); // } // var_dump($charts); // die; return $data; }
public function cancelTrans() { $inputs = Input::all(); $cancel = new Cancellation(); $cancel->tran_id = $inputs['tran_id']; $cancel->who_id = $inputs['who_id']; $cancel->reason = $inputs['reason']; $cancel->who = $inputs['who']; if ($cancel->save()) { DealTransaction::delete(); return Redirect::to('transaction')->with('success', 'Cancel the successfully'); } return Redirect::to('transaction')->with('error', 'There was an issue cancelling the transaction. Please try again.'); }
/** * Remove the specified outlet from storage. * * @param int $id * @return Response */ public function destroyDeal($id) { DealTransaction::where('deal_id', $id)->delete(); Deal::destroy($id); return Redirect::to('admin/deals'); }
public function getDashboardDataPastWeek() { return DealTransaction::pastWeek(); }
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('/'); }
public function getPaymentStatus() { // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); $bill_id = Session::get('bill_id'); // clear the session payment ID Session::forget('paypal_payment_id'); Session::forget('bill_id'); if (empty(Input::get('PayerID')) || empty(Input::get('token'))) { return Redirect::route('original.route')->with('error', 'Payment failed'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); // echo '<pre>';print_r($result);echo '</pre>';exit; // DEBUG RESULT, remove it later if ($result->getState() == 'approved') { // payment made $Bill = DealTransaction::find($bill_id); $Bill->payment_status = 1; $Bill->status = 1; $Bill->payment_id = $payment_id; $Bill->save(); echo '<center><h1>PAID SUCCESSFULLY!!!</h1><center><p>Please wait while we redirecting to homepage</p></center></center><script>setTimeout(function(){ location.href="/../"; }, 3000);</script>'; die; } //return Redirect::route('original.route'); echo '<center><h1>PAID FAILED!!!</h1></center><center><p>Please wait while we redirecting to homepage</p></center><script>setTimeout(function(){ location.href="/../"; }, 3000);</script>'; die; }
/** * 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 }
public function cancellationDeal() { $title = 'Cancellation Deal'; $deals = DealTransaction::cancellation(); return View::make('site.deals.cancellation', compact('deals', 'title')); }