057-filament-v5-upgrade #66

Merged
ahmido merged 23 commits from 057-filament-v5-upgrade into dev 2026-01-20 21:19:28 +00:00
Showing only changes of commit b807a7bb96 - Show all commits

View File

@ -11,11 +11,14 @@
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use RuntimeException;
use Throwable;
class BulkBackupSetRestoreJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $bulkRunId = 0;
public ?OperationRun $operationRun = null;
/**
@ -30,13 +33,12 @@ public function __construct(
public array $context = [],
) {
$this->operationRun = $operationRun;
$this->bulkRunId = $operationRun?->getKey() ? (int) $operationRun->getKey() : 0;
}
public function handle(OperationRunService $runs): void
{
if (! $this->operationRun instanceof OperationRun) {
throw new RuntimeException('OperationRun is required for BulkBackupSetRestoreJob.');
}
$this->operationRun = $this->resolveOperationRun();
$this->operationRun->refresh();
@ -66,6 +68,49 @@ public function handle(OperationRunService $runs): void
}
}
public function failed(Throwable $e): void
{
$run = $this->operationRun;
if (! $run instanceof OperationRun && $this->bulkRunId > 0) {
$run = OperationRun::query()->find($this->bulkRunId);
}
if (! $run instanceof OperationRun) {
return;
}
/** @var OperationRunService $runs */
$runs = app(OperationRunService::class);
$runs->updateRun(
$run,
status: 'completed',
outcome: 'failed',
failures: [[
'code' => 'bulk_job.failed',
'message' => $e->getMessage(),
]],
);
}
private function resolveOperationRun(): OperationRun
{
if ($this->operationRun instanceof OperationRun) {
return $this->operationRun;
}
if ($this->bulkRunId > 0) {
$run = OperationRun::query()->find($this->bulkRunId);
if ($run instanceof OperationRun) {
return $run;
}
}
throw new RuntimeException('OperationRun is required for BulkBackupSetRestoreJob.');
}
/**
* @param array<int, mixed> $ids
* @return array<int, int>