/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { if ($request->holder_name == ('Suchay Janbandhu' && 'suchay janbandhu') && $request->card_number == '1234567890' && $request->month == 'Jul (07)' && $request->year == '2021' && $request->cvv == '123') { $account = Bankncash::DefaultApartment()->find(18); $bal = $account->balance; $amount = 787; $nbal = $bal + $amount; Bankncash::find(18)->update(['balance' => $nbal]); Transaction::create(['apartment_id' => Auth::user()->profile->defaultApartment, 'account_id' => 18, 'type' => 'Income', 'category_id' => 61, 'amount' => 787, 'payer_id' => Auth::user()->profile->id, 'payment_id' => $request->payment_id, 'cr' => 787, 'bal' => $nbal, 'description' => 'Maintenance Payment for the Month of ' . Carbon::now()->month, 'date' => Carbon::now()]); return redirect()->route('user.home')->withMessage('Transaction Completed Successfully')->withStatus('success'); } else { return redirect()->route('user.home')->withMessage('Transaction Could not complete')->withStatus('error'); } }
public function postAccountStatement(Request $request) { $account = Bankncash::find($request->account_id); $from_date = $request->from_date; $to_date = $request->to_date; $type = $request->type; if ($type == 'Debit') { $lists = Transaction::whereBetween('date', [$from_date, $to_date])->where('account_id', '=', $account->id)->where('dr', '!=', '0.00')->orderBy('date', 'DESC')->get(); } elseif ($type == 'Credit') { $lists = Transaction::whereBetween('date', [$from_date, $to_date])->where('account_id', '=', $account->id)->where('cr', '!=', '0.00')->orderBy('date', 'DESC')->get(); } else { $lists = Transaction::whereBetween('date', [$from_date, $to_date])->where('account_id', '=', $account->id)->orderBy('date', 'DESC')->get(); } // dd($lists); return view('reports.accstatement', compact('account', 'from_date', 'to_date', 'lists', 'type')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { try { $list = Transaction::findOrFail($id); $account = Bankncash::find($list->account_id); $bal = $account->balance; $amount = $list->amount; $nbal = $bal + $amount; $account->update(['balance' => $nbal]); $list->delete(); } catch (Exception $e) { return redirect()->back()->withMessage('Error deleting Expense, Possibly it is already Deleted')->withStatus('error'); } return redirect()->route('expense.index', compact('list'))->withMessage('Expenses has been Deleted')->withStatus('success'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { try { $list = Transaction::find($id); $previd = $list->id - 1; $prevlist = Transaction::find($previd); $amount = $list->amount; $sourcebankid = Transaction::find($previd)->account_id; $tobankid = Transaction::find($id)->account_id; $from_balance = Bankncash::find($sourcebankid)->balance; $to_balance = Bankncash::find($tobankid)->balance; $newfrom_bal = $from_balance + $amount; $newto_bal = $to_balance - $amount; Bankncash::find($sourcebankid)->update(['balance' => $newfrom_bal]); Bankncash::find($tobankid)->update(['balance' => $newto_bal]); $list->delete(); $prevlist->delete(); } catch (Exception $e) { return redirect()->back()->withMessage('Error Reverting Transaction, Possibly it is already Deleted')->withStatus('error'); } return redirect()->back()->withMessage('Transfer Reverted')->withStatus('success'); }