*/ 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 int $languageId, private readonly array $translateTextCode = [], private readonly array $exceptLanguages = [], ) { } /** * Get the unique ID for the job. */ public function uniqueId(): string { return 'ProcessTranslationText-' . $this->projectId; } /** * Execute the job. * @throws Exception */ public function handle(TranslationTextService $translationTextService): void { $result = $translationTextService->translate($this->projectId, $this->languageId, $this->translateTextCode, $this->exceptLanguages); if ($result->isError() && $result->getCode() !== 404) { cache()->lock($this->uniqueId())->forceRelease(); throw new Exception($result->getMessage()); } } }