예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(LoanApplicationRequest $request)
 {
     $lrq = new LoanApplication();
     $lrq->loan_id = $request->loan_id;
     $lrq->member_id = Auth::user()->member->id;
     $lrq->terms = $request->terms;
     $lrq->amountGranted = $request->amount;
     $lrq->comaker = $request->comaker;
     $lrq->save();
     flash()->success("We have received your loan application. Please wait for it's appoval");
     return redirect('/');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(LoanApprovalRequest $request)
 {
     $appli = LoanApplication::findOrFail($request->id);
     //$appli->accepted = $request::get('accept');
     //$appli->save();
     //if($appli->accepted=='true'){
     if ($request->accept == 'true') {
         $acc = new Account();
         $acc->loan_id = $appli->loan_id;
         $acc->member_id = $appli->member_id;
         $acc->terms = $appli->terms;
         $acc->amountGranted = $appli->amountGranted;
         $acc->comaker = $appli->comaker;
         $acc->dateGranted = $request->date;
         $acc->dueDate = $acc->dateGranted;
         $acc->dueDate->addDays($acc->terms);
         $acc->balance = $acc->amountGranted;
         $acc->save();
         $ledger = new Ledger();
         $ledger->account_id = $acc->id;
         $ledger->curDate = $acc->dateGranted;
         $ledger->particulars = $request->particular;
         $ledger->reference = $request->reference;
         $ledger->avaiment = $acc->amountGranted;
         $ledger->amountPayed = 0;
         $ledger->interestDue = 0.0;
         $ledger->penaltyDue = 0.0;
         $ledger->principal = 0.0;
         $ledger->interestPayed = 0.0;
         $ledger->penaltyPayed = 0.0;
         $ledger->balance = $acc->amountGranted;
         $acc->balance = $acc->amountGranted;
         //toodo
         $ledger->save();
     }
     $appli->delete();
     flash()->success("Success!");
     return redirect('/admin');
 }