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,75 @@
<?php
namespace App\Filament\Resources\NavigationItems;
use App\Domain\Cms\NavigationItem;
use App\Domain\Cms\Page;
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
use Closure;
use Filament\Forms\Components\Select;
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 NavigationItemResource extends Resource
{
protected static ?string $model = NavigationItem::class;
protected static ?string $navigationLabel = 'Navigation';
protected static ?string $modelLabel = 'Navigationspunkt';
protected static ?string $pluralModelLabel = 'Navigation';
public static function form(Schema $schema): Schema
{
return $schema->components([
TextInput::make('label')->label('Beschriftung')->required()->maxLength(80),
Select::make('page_id')
->label('Seite')
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
->searchable(),
TextInput::make('url')
->label('Adresse')
->maxLength(500)
->rule(function (Get $get): Closure {
return function (string $attribute, mixed $value, Closure $fail) use ($get): void {
if (blank($get('page_id')) && blank($value)) {
$fail('Wählen Sie eine Seite oder eine Adresse.');
}
};
}),
Select::make('placement')
->label('Platz')
->options([
'header' => 'Kopfzeile',
'footer' => 'Fußzeile',
])
->required(),
TextInput::make('sort_order')->label('Reihenfolge')->numeric()->required()->default(0),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('label')->label('Beschriftung'),
TextColumn::make('page.path')->label('Seite'),
TextColumn::make('url')->label('Adresse'),
TextColumn::make('placement')->label('Platz'),
TextColumn::make('sort_order')->label('Reihenfolge')->sortable(),
])
->defaultSort('sort_order');
}
public static function getPages(): array
{
return [
'index' => ManageNavigationItems::route('/'),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\NavigationItems\Pages;
use App\Filament\Resources\NavigationItems\NavigationItemResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ManageRecords;
class ManageNavigationItems extends ManageRecords
{
protected static string $resource = NavigationItemResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -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');
}
}
@@ -0,0 +1,20 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
return UserResource::persist(new ($this->getModel()), $data, true);
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Database\Eloquent\Model;
class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeFill(array $data): array
{
$data['roles'] = $this->record->staffRoles->map(fn ($assignment) => $assignment->role->value)->all();
$data['status'] = $this->record->status->value;
return $data;
}
/**
* @param array<string, mixed> $data
*/
protected function handleRecordUpdate(Model $record, array $data): Model
{
return UserResource::persist($record, $data, false);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,115 @@
<?php
namespace App\Filament\Resources\Users;
use App\Domain\Identity\AccountStatus;
use App\Domain\Identity\AssignStaffRoles;
use App\Domain\Identity\RegisterAccount;
use App\Domain\Identity\StaffRole;
use App\Filament\Resources\Users\Pages\CreateUser;
use App\Filament\Resources\Users\Pages\EditUser;
use App\Filament\Resources\Users\Pages\ListUsers;
use App\Models\User;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $navigationLabel = 'Benutzer';
protected static ?string $modelLabel = 'Benutzer';
protected static ?string $pluralModelLabel = 'Benutzer';
protected static ?string $recordTitleAttribute = 'email';
public static function form(Schema $schema): Schema
{
return $schema->components([
TextInput::make('name')->label('Name')->required()->maxLength(120),
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
TextInput::make('password')
->label('Passwort')
->password()
->revealable()
->required(fn (string $operation): bool => $operation === 'create')
->dehydrated(fn (?string $state): bool => filled($state))
->minLength(8),
Select::make('status')
->label('Status')
->options(collect(AccountStatus::cases())->mapWithKeys(
fn (AccountStatus $status): array => [$status->value => $status->label()],
)->all())
->required()
->default(AccountStatus::Aktiv->value),
CheckboxList::make('roles')
->label('Personalrollen')
->options(StaffRole::options())
->columns(2),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->label('Name')->searchable(),
TextColumn::make('email')->label('E-Mail')->searchable(),
TextColumn::make('status')->label('Status')->formatStateUsing(
fn (AccountStatus|string|null $state): string => $state instanceof AccountStatus ? $state->label() : (string) $state,
),
TextColumn::make('staffRoles.role')
->label('Rollen')
->badge()
->formatStateUsing(fn (StaffRole|string $state): string => $state instanceof StaffRole ? $state->label() : StaffRole::from($state)->label()),
]);
}
public static function getPages(): array
{
return [
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'edit' => EditUser::route('/{record}/edit'),
];
}
/**
* @param array<string, mixed> $data
*/
public static function persist(User $user, array $data, bool $creating): User
{
$roles = $data['roles'] ?? [];
unset($data['roles']);
if ($creating) {
$user = app(RegisterAccount::class)->register(
$data['name'],
$data['email'],
$data['password'],
true,
);
$user->forceFill([
'status' => $data['status'],
'email_verified_at' => now(),
])->save();
} else {
if (blank($data['password'] ?? null)) {
unset($data['password']);
}
$user->update($data);
}
app(AssignStaffRoles::class)->sync($user, $roles, auth()->user());
return $user;
}
}