label('Artikel anlegen') ->schema([ TextInput::make('code')->label('Kennung')->required(), TextInput::make('product_line')->label('Produktlinie'), ]) ->action(function (array $data): void { $this->report(function () use ($data): void { app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null); }, 'Der Lizenzartikel ist angelegt.'); }), Action::make('release') ->label('Stand veröffentlichen') ->schema([ Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())->required(), Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(), Textarea::make('classification')->label('Einordnung')->required(), TextInput::make('change_note')->label('Änderungshinweis'), ]) ->action(function (array $data): void { $this->report(function () use ($data): string { [$type, $id] = explode(':', $data['root'], 2); $root = $type === 'composition' ? CompositionVersion::query()->findOrFail($id) : ContentElementVersion::query()->findOrFail($id); $release = app(ArticleService::class)->publishRelease( LicenseArticle::query()->findOrFail($data['article_id']), $root, $data['classification'], $data['change_note'] ?? null, ); $report = $release->impact_report ?? []; $offers = $report['offers'] ?? []; return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0) .', Inhaber: '.($report['holders'] ?? 0) .', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.'; }, 'Der Artikel-Stand ist veröffentlicht.'); }), Action::make('withdraw') ->label('Stand zurückziehen') ->schema([ Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())->required(), Textarea::make('reason')->label('Begründung')->required(), ]) ->action(function (array $data): void { $this->report(function () use ($data): string { $result = app(ArticleService::class)->withdraw( LicenseArticle::query()->findOrFail($data['article_id']), $data['reason'], ); $current = $result['fallback_number'] === null ? 'Es gibt keinen früheren Stand.' : 'Aktuell ist wieder Stand '.$result['fallback_number'].'.'; $holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']); return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.'; }, 'Der Stand ist zurückgezogen.'); }), ]; } }