card action

This commit is contained in:
2025-01-26 14:42:47 +03:00
parent 08cdf44b67
commit 824130df26
27 changed files with 430 additions and 53 deletions

View File

@ -24,6 +24,7 @@ class CardTransactionService
$this->errors[] = ["error_id" => 3, "error_msg" => "Sender not found"];
return false;
}
$model->from_balance = $fromCard->balance;
}
if ($toId !== 1001){
@ -32,6 +33,7 @@ class CardTransactionService
$this->errors[] = ["error_id" => 3, "error_msg" => "Recipient not found"];
return false;
}
$model->to_balance = $toCard->balance;
}
if ($fromId !== 1001){
@ -49,11 +51,11 @@ class CardTransactionService
// $model->slug = Slug::createSlug($form_model->getItem('title'), Card::class); // Генерация уникального slug
if ($model->save()) {
if ($fromCard){
if (isset($fromCard)){
$fromCard->balance = $fromCard->balance - (int)$form_model->getItem('amount');
$fromCard->save();
}
if ($toCard){
if (isset($toCard)){
$toCard->balance = $toCard->balance + (int)$form_model->getItem('amount');
$toCard->save();
}