*/ public function middleware(): array { return [ (new WithoutOverlapping($this->uniqueId()))->expireAfter(180), ]; } /** * Create a new job instance. */ public function __construct( private readonly int $projectId, private readonly array $contentIds = [], private readonly array $exceptLanguages = [], ) { } /** * Get the unique ID for the job. */ public function uniqueId(): string { return 'project-' . $this->projectId; } /** * Execute the job. * @throws Exception */ public function handle(ProjectContentService $projectContentService): void { $result = $projectContentService->translate($this->projectId, $this->contentIds, $this->exceptLanguages); if ($result->isError() && $result->getCode() !== 404) { cache()->lock($this->uniqueId())->forceRelease(); throw new Exception($result->getMessage()); } } }