get(self::BLOCK) !== null; } /** * @return array ID => Titel */ public static function options(): array { $field = collect(app(Blocks::class)->get(self::BLOCK)?->fields ?? [])->first(fn ($f) => $f->name === 'form'); return $field ? collect($field->toArray()['choices'] ?? [])->pluck('label', 'value')->all() : []; } /** * Anzeigefertiger Inhalt (wie eine Pagebuilder-Seite mit einem Block) oder null. * * @return array|null */ public static function render(?int $formId, ?User $user): ?array { if (! $formId || ! self::available()) { return null; } $content = app(Content::class); $rendered = $content->render($content->sanitize(['blocks' => [['type' => self::BLOCK, 'data' => ['form' => (string) $formId, 'show_title' => true]]]]), $user); return $rendered['blocks'] === [] ? null : $rendered; } }