Zeige im Katalog, wie Inhalte, Pakete und Rechte zusammenhängen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fa706e5080
commit
cd79fb99d7
22 files changed
+1066
-200
No files matched your search
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Bundles\Pages;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewBundle extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')
|
||||
->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();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user