Files
MKM/app/Commands/Account/CreateAccountCommand.php
2024-08-11 20:03:49 +08:00

23 lines
564 B
PHP

<?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
);
}
}