detailsFactory->build($data); $year = (int) $this->clock->today()->format('Y'); return $this->transactions->run(function () use ($details, $year, $actorUserId): int { $job = CustomerJob::open($this->numbers->next($year), $details, $actorUserId); $job->recordCompletion($this->clock->now()); $jobId = (int) $this->jobs->save($job)->id(); $this->jobs->recordChanges($jobId, $actorUserId, [new FieldChange('created', null, $job->number()->format())]); return $jobId; }); } }