Beispiel #1
0
 /**
  * Update the specified share in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $share = Share::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Share::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $share->value = Input::get('value');
     $share->transfer_charge = Input::get('transfer_charge');
     $share->charged_on = Input::get('charged_on');
     $share->update();
     return Redirect::to('shares/show/' . $share->id);
 }
 /**
  * Display the specified sharetransaction.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $account = Shareaccount::findOrFail($id);
     $credit = DB::table('sharetransactions')->where('shareaccount_id', '=', $account->id)->where('type', '=', 'credit')->sum('amount');
     $debit = DB::table('sharetransactions')->where('shareaccount_id', '=', $account->id)->where('type', '=', 'debit')->sum('amount');
     $balance = $credit - $debit;
     $sh = Share::findOrFail(1);
     $sharevalue = $sh->value;
     if ($sharevalue != 0) {
         $shares = $balance / $sharevalue;
     } else {
         $shares = 0;
     }
     return View::make('sharetransactions.show', compact('account', 'shares'));
 }