feat: initial commit
This commit is contained in:
20
app/Commands/Branches/CreateBranchCommand.php
Normal file
20
app/Commands/Branches/CreateBranchCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Branches;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Branch;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateBranchCommand implements Command
|
||||
{
|
||||
public function execute(array $data): \Illuminate\Database\Eloquent\Model
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn() => Branch::query()->updateOrCreate(['id' => $data['id'] ?? null], Arr::except($data, ['series'])),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user