transactions->run(function () use ($templateId, $active): void { $template = $this->templates->findById($templateId) ?? throw new WorkflowTemplateNotFound($templateId); $active ? $template->activate() : $template->deactivate(); $this->templates->save($template); }); } }