Answer the question
In order to leave comments, you need to log in
How to sum up the incoming data with the data already available in the database?
In my form I have something like this:
<input type="hidden" name="purse_balance" id="Purse-purse_balance" class="form-control">
public function trans(Request $request){
$balance = new Purse;
$transactions = new Transaction;
$transactions->trans_pay_sum = $request->trans_pay_sum;
$transactions->trans_pay_appoint = $request->trans_pay_appoint;
$transactions->trans_pay_purse_name = $request->trans_pay_purse_name;
$transactions->trans_pay_purse_client_id = Auth::id();
$balance->purse_balance = $request->purse_balance;
if($request->get('page') == 'moneyfill')
{
$this->purse($request);
}
}
public function purse(Request $request){
$purse = new Purse;
$balance = new Purse;
$purse = Purse::where('purse_name', $request->trans_pay_purse_name)->first();
$balance = $request->purse_balance;
$result= $request->trans_pay_sum;
$balance=$result+$balance;
$purse->purse_balance = $balance;
$purse->save();
return view('home');
}
trans_pay_sum
added to the amount already available purse_balance
. Answer the question
In order to leave comments, you need to log in
$purse->increment('purse_balanse', $request->trans_pay_sum);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question