Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | public function debit(int $amount, array $eTIDs = []): Wallet | ||||
$this->save(); | $this->save(); | ||||
$transaction = \App\Transaction::create( | $transaction = \App\Transaction::create( | ||||
[ | [ | ||||
'object_id' => $this->id, | 'object_id' => $this->id, | ||||
'object_type' => \App\Wallet::class, | 'object_type' => \App\Wallet::class, | ||||
'type' => \App\Transaction::WALLET_DEBIT, | 'type' => \App\Transaction::WALLET_DEBIT, | ||||
'amount' => $amount | 'amount' => $amount * -1 | ||||
] | ] | ||||
); | ); | ||||
\App\Transaction::whereIn('id', $eTIDs)->update(['transaction_id' => $transaction->id]); | \App\Transaction::whereIn('id', $eTIDs)->update(['transaction_id' => $transaction->id]); | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |