feat: updates
This commit is contained in:
22
app/Commands/Account/CreateAccountCommand.php
Normal file
22
app/Commands/Account/CreateAccountCommand.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Account;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Account;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateAccountCommand implements Command
|
||||
{
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => Account::query()->updateOrCreate([
|
||||
'id' => $data['id'] ?? null,
|
||||
'client_id' => $data['client_id'],
|
||||
], Arr::except($data, ['starting_balance', 'branch_id'])),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
28
app/Commands/Account/CreateBalanceCommand.php
Normal file
28
app/Commands/Account/CreateBalanceCommand.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Account;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Balance;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateBalanceCommand implements Command
|
||||
{
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => Balance::query()->updateOrCreate(
|
||||
[
|
||||
'id' => $data['id'] ?? null,
|
||||
'account_id' => $data['account_id'],
|
||||
'is_starting' => isset($data['starting_balance']),
|
||||
'branch_id' => $data['branch_id'] ?? null,
|
||||
],
|
||||
[
|
||||
'balance' => $data['starting_balance'],
|
||||
]
|
||||
),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user