Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Deploy Test / test (push) Successful in 2m25s
Deploy Test / deploy (push) Failing after 25s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 08:32:14 +01:00
1 parent 89b35ac480
commit 2035c46edd
130 files changed
+18519 -50

No files matched your search

@@ -0,0 +1,132 @@
<?php
namespace App\Filament\Resources\Pages;
use App\Domain\Cms\Blocks\BlockRegistry;
use App\Domain\Cms\Page;
use App\Filament\Resources\Pages\Pages\CreatePage;
use App\Filament\Resources\Pages\Pages\EditPage;
use App\Filament\Resources\Pages\Pages\ListPages;
use App\Filament\Resources\Pages\RelationManagers\RevisionsRelationManager;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class PageResource extends Resource
{
protected static ?string $model = Page::class;
protected static ?string $navigationLabel = 'Seiten';
protected static ?string $modelLabel = 'Seite';
protected static ?string $pluralModelLabel = 'Seiten';
protected static ?string $recordTitleAttribute = 'path';
public static function form(Schema $schema): Schema
{
$labels = app(BlockRegistry::class)->labels();
return $schema->components([
TextInput::make('path')
->label('Pfad')
->required()
->maxLength(255)
->helperText('Zum Beispiel / oder /praevention'),
TextInput::make('seo_title')
->label('SEO-Titel')
->maxLength(255),
Textarea::make('seo_description')
->label('SEO-Beschreibung')
->maxLength(500)
->columnSpanFull(),
Repeater::make('blocks')
->label('Bausteine')
->schema([
Select::make('type')
->label('Typ')
->options($labels)
->required()
->live(),
TextInput::make('heading')
->label('Überschrift')
->visible(fn (Get $get): bool => in_array($get('type'), ['heading', 'call_to_action'], true)),
Textarea::make('intro')
->label('Einleitung')
->visible(fn (Get $get): bool => $get('type') === 'heading'),
Textarea::make('body')
->label('Text')
->visible(fn (Get $get): bool => in_array($get('type'), ['prose', 'image_text'], true))
->columnSpanFull(),
FileUpload::make('image')
->label('Bild')
->disk('cms_incoming')
->directory('cms')
->image()
->visible(fn (Get $get): bool => $get('type') === 'image_text'),
TextInput::make('alt')
->label('Alternativtext')
->visible(fn (Get $get): bool => $get('type') === 'image_text'),
Textarea::make('text')
->label('Text')
->visible(fn (Get $get): bool => $get('type') === 'call_to_action'),
TextInput::make('label')
->label('Beschriftung der Aktion')
->visible(fn (Get $get): bool => $get('type') === 'call_to_action'),
TextInput::make('url')
->label('Adresse')
->visible(fn (Get $get): bool => $get('type') === 'call_to_action'),
Repeater::make('items')
->label('Einträge')
->visible(fn (Get $get): bool => in_array($get('type'), ['cards', 'faq'], true))
->schema([
TextInput::make('title')->label('Titel')->visible(fn (Get $get): bool => $get('../../type') === 'cards'),
Textarea::make('text')->label('Text')->visible(fn (Get $get): bool => $get('../../type') === 'cards'),
TextInput::make('url')->label('Adresse')->visible(fn (Get $get): bool => $get('../../type') === 'cards'),
TextInput::make('question')->label('Frage')->visible(fn (Get $get): bool => $get('../../type') === 'faq'),
Textarea::make('answer')->label('Antwort')->visible(fn (Get $get): bool => $get('../../type') === 'faq'),
]),
])
->columnSpanFull()
->reorderable()
->collapsed(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('path')->label('Pfad')->searchable(),
TextColumn::make('published_revision_id')
->label('Veröffentlicht')
->formatStateUsing(fn ($state): string => $state ? 'Ja' : 'Entwurf'),
TextColumn::make('updated_at')->label('Geändert')->dateTime('d.m.Y H:i'),
])
->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record]));
}
public static function getRelations(): array
{
return [
RevisionsRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => ListPages::route('/'),
'create' => CreatePage::route('/create'),
'edit' => EditPage::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Filament\Resources\Pages\Pages;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Filament\Resources\Pages\PageResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
class CreatePage extends CreateRecord
{
protected static string $resource = PageResource::class;
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$service = app(PageService::class);
$page = Page::query()->create([
'path' => $service->normalizePath($data['path']),
]);
$service->saveRevision(
$page,
$data['blocks'] ?? [],
$data['seo_title'] ?? null,
$data['seo_description'] ?? null,
auth()->user(),
);
return $page;
}
}
@@ -0,0 +1,77 @@
<?php
namespace App\Filament\Resources\Pages\Pages;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Filament\Resources\Pages\PageResource;
use Filament\Actions\Action;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model;
class EditPage extends EditRecord
{
protected static string $resource = PageResource::class;
protected function getHeaderActions(): array
{
return [
Action::make('preview')
->label('Vorschau')
->url(function (): string {
$revision = $this->record->latestRevision;
return $revision === null
? '#'
: route('pages.preview', $revision);
})
->openUrlInNewTab(),
Action::make('publish')
->label('Veröffentlichen')
->requiresConfirmation()
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
->action(function (PageService $service): void {
$revision = $this->record->latestRevision;
abort_if($revision === null, 404);
$service->publish($this->record, $revision);
$this->record->refresh();
}),
];
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeFill(array $data): array
{
$revision = $this->record->latestRevision ?? $this->record->publishedRevision;
$data['blocks'] = $revision?->blocks ?? [];
$data['seo_title'] = $revision?->seo_title;
$data['seo_description'] = $revision?->seo_description;
return $data;
}
/**
* @param array<string, mixed> $data
*/
protected function handleRecordUpdate(Model $record, array $data): Model
{
/** @var Page $record */
$service = app(PageService::class);
$record->update([
'path' => $service->normalizePath($data['path']),
]);
$service->saveRevision(
$record,
$data['blocks'] ?? [],
$data['seo_title'] ?? null,
$data['seo_description'] ?? null,
auth()->user(),
);
return $record;
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Pages\Pages;
use App\Filament\Resources\Pages\PageResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListPages extends ListRecords
{
protected static string $resource = PageResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,48 @@
<?php
namespace App\Filament\Resources\Pages\RelationManagers;
use App\Domain\Cms\PageRevision;
use App\Domain\Cms\PageService;
use Filament\Actions\Action;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class RevisionsRelationManager extends RelationManager
{
protected static string $relationship = 'revisions';
protected static ?string $title = 'Revisionen';
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->label('Nr.'),
TextColumn::make('created_at')->label('Gespeichert')->dateTime('d.m.Y H:i'),
TextColumn::make('author.name')->label('Von'),
TextColumn::make('published')
->label('Live')
->state(fn (PageRevision $record): string => $record->id === $this->getOwnerRecord()->published_revision_id ? 'Ja' : 'Nein'),
])
->recordActions([
Action::make('publish')
->label('Veröffentlichen')
->requiresConfirmation()
->visible(fn (): bool => auth()->user()?->can('publish', $this->getOwnerRecord()) ?? false)
->action(function (PageRevision $record, PageService $service): void {
$service->publish($this->getOwnerRecord(), $record);
$this->getOwnerRecord()->refresh();
}),
Action::make('restore')
->label('Wiederherstellen')
->requiresConfirmation()
->modalDescription('Es entsteht eine neue Revision. Die Live-Seite bleibt unverändert, bis sie veröffentlicht wird.')
->action(function (PageRevision $record, PageService $service): void {
$service->restore($this->getOwnerRecord(), $record, auth()->user());
}),
])
->defaultSort('id', 'desc');
}
}