/**
  * Update the specified shareaccount in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $shareaccount = Shareaccount::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Shareaccount::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $shareaccount->update($data);
     return Redirect::route('shareaccounts.index');
 }
 /**
  * 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'));
 }