label('Fassung veröffentlichen') ->schema([ CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()), CheckboxList::make('bundles')->label('Enthaltene Pakete') ->options(function (): array { $options = CatalogOptions::bundles(); unset($options[$this->getRecord()->getKey()]); return $options; }), ]) ->action(function (array $data): void { $this->report(function () use ($data): void { /** @var Bundle $bundle */ $bundle = $this->getRecord(); $items = []; foreach ($data['articles'] ?? [] as $id) { $items[] = LicenseArticle::query()->findOrFail($id); } foreach ($data['bundles'] ?? [] as $id) { $items[] = Bundle::query()->findOrFail($id); } app(BundleService::class)->publish($bundle, $items); }, 'Die Paketfassung ist veröffentlicht.'); $this->getRecord()->unsetRelations(); $this->getRecord()->refresh(); }), ]; } }