28 lines
890 B
PHP
28 lines
890 B
PHP
<?php
|
|
|
|
namespace App\Commands\Ledgers;
|
|
|
|
use App\Commands\Command;
|
|
use App\Models\Ledger;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CreateLedgerCommand implements Command
|
|
{
|
|
public function execute(array $data): mixed
|
|
{
|
|
return DB::transaction(function () use ($data) {
|
|
return Ledger::query()->updateOrCreate([
|
|
'id' => $data['id'] ?? null,
|
|
'transaction_id' => $data['transaction_id'] ?? null,
|
|
'account_id' => $data['account_id'] ?? null,
|
|
], [
|
|
'credit_amount' => $data['credit_amount'] ?? null,
|
|
'debit_amount' => $data['debit_amount'] ?? null,
|
|
'description' => $data['description'] ?? null,
|
|
'branch_id' => $data['branch_id'] ?? null,
|
|
'client_id' => $data['client_id'] ?? null,
|
|
]);
|
|
}, attempts: 2);
|
|
}
|
|
}
|