Answer the question
In order to leave comments, you need to log in
How to update data in database after button click, Laravel?
I have two tables: Purses and Transactions. The Purses table has a purse_balance field. After the transaction is completed, it must be updated, i.e. something is added to the previous value. I wrote the code, but it is of little use, because errors fly out:
public function trans(Request $request){
$transactions = new Transaction;
$transactions->trans_pay_sum = $request->trans_pay_sum;
$transactions->trans_pay_appoint = $request->trans_pay_appoint;
$transactions->trans_pay_purse_id = $request->trans_pay_purse_id;
$transactions->trans_pay_purse_client_id = Auth::id();
$transactions->save();
$purses = new Purse;
$purses->purse_name = $request->trans_pay_purse_id;
$purses->purse_balance = $this->sum($request);
$purses->save();
return view('home');
}
public function sum( Request $request){
$result = '';
$result= $request->trans_pay_sum;
return $result;
}
Answer the question
In order to leave comments, you need to log in
Duplicate entry '3774817312069704'There was the same problem, then either the key went out of range, or the disk space ran out, I don’t remember, but the table was quite large in size. Clearing the table helped.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question