Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
463851d402
commit
fd6860efda
51 files changed
+2331
-31
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?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\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBundles extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = BundleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')->label('Paket anlegen')->schema([
|
||||
TextInput::make('name')->label('Name')->required(),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(BundleService::class)->create($data['name']);
|
||||
}, 'Das Paket ist angelegt.');
|
||||
}),
|
||||
Action::make('publish')->label('Fassung veröffentlichen')->schema([
|
||||
Select::make('bundle_id')->label('Paket')->options(fn (): array => CatalogOptions::bundles())->required(),
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')->options(fn (): array => CatalogOptions::bundles()),
|
||||
])->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$items = [];
|
||||
|
||||
foreach ($data['articles'] ?? [] as $id) {
|
||||
$items[] = LicenseArticle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
foreach ($data['bundles'] ?? [] as $id) {
|
||||
if ((int) $id === (int) $data['bundle_id']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$items[] = Bundle::query()->findOrFail($id);
|
||||
}
|
||||
|
||||
app(BundleService::class)->publish(Bundle::query()->findOrFail($data['bundle_id']), $items);
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user