public function getRolloverCancel($id, Rollover $rollover, Payment $payment) { $customer_rollover = $rollover->whereId((int) $id)->first(); $amount = $customer_rollover->rollover_amount; $rollover_from_id = $customer_rollover->rollover_from_user; $rollover_to_id = $customer_rollover->rollover_to_user; $delete = $rollover->whereId((int) $id)->delete(); if ($delete) { $payment->where('customer_id', (int) $rollover_from_id)->increment('account_balance', $amount); $payment->where('customer_id', (int) $rollover_to_id)->decrement('account_balance', $amount); flash()->success(nairaFormater($amount) . ' has been rolled over from ' . customerFullname($rollover_to_id) . ' to ' . customerFullname($rollover_from_id) . '!'); } else { flash()->error('An error occurred while rolling over ' . nairaFormater($amount) . ' back to ' . customerFullname($rollover_from_id) . '!'); } return redirect()->back(); }
public function postNewTopUp(NewTopUpRequest $request, Payment $payment) { $customer_id = thcToCustomerId($request->input('customer_thc')); $topup_amount = (int) $request->input('topup_amount'); $topup = $payment->where('customer_id', $customer_id)->increment('account_balance', $topup_amount); if ($topup) { flash()->success(nairaFormater($topup_amount) . ' was added to ' . customerFullname($customer_id) . '\'s Account!'); } else { flash()->error('An error occurred while topping up ' . customerFullname($customer_id) . '\'s Account!'); } return redirect()->route('customer.list'); }
public function getOrderCancel($id, Order $order, Payment $payment) { $customer_order = $order->whereId((int) $id)->first(); $amount = $customer_order->order_amount; $customer_id = $customer_order->customer_id; $delete = $order->whereId((int) $id)->delete(); if ($delete) { // ->increment('votes', 5); $payment->where('customer_id', (int) $customer_id)->increment('account_balance', $amount); flash()->success('Order #' . $id . ' has been cancelled and ' . nairaFormater($amount) . ' refunded to ' . customerFullname($customer_id) . '!'); } else { flash()->error('An error occurred while cancelling Order #' . $id . '!'); } return redirect()->back(); }