Files
fewo-stommer/app/Filament/Resources/Pages/Schemas/PageForm.php
T
Lars Stommer abf0e9004b
Deploy / test (push) Failing after 2m47s
Deploy / deploy (push) Skipped
Wohnung je Baustein wählen und Gitea-Runner-Kompatibilität herstellen
2026-10-26 08:23:14 +01:00

68 lines
3.1 KiB
PHP

<?php
namespace App\Filament\Resources\Pages\Schemas;
use App\Models\Page;
use App\Models\Site;
use App\Themes\SectionRegistry;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Validation\Rules\Unique;
class PageForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(3)
->components([
Section::make('Bausteine')
->description('Die Seite besteht aus Bausteinen. Reihenfolge per Ziehen, Inhalte je Baustein. Wie sie aussehen, bestimmt das Theme.')
->columnSpan(2)
->schema([
Builder::make('sections')
->hiddenLabel()
->blocks(fn (callable $get): array => app(SectionRegistry::class)->blocks($get('site_id')))
->addActionLabel('Baustein hinzufügen')
->collapsible()
->collapsed()
->cloneable()
->blockNumbers(false)
->blockPickerColumns(2),
]),
Section::make('Seite')
->columnSpan(1)
->schema([
Hidden::make('site_id')->default(fn (): ?int => Site::query()->where('is_default', true)->value('id') ?? Site::query()->value('id')),
TextInput::make('title')->label('Titel')->required()->maxLength(120),
TextInput::make('slug')
->label('Adresse')
->prefix('/')
->helperText('Die Startseite heißt „start“.')
->required()
->alphaDash()
->maxLength(80)
->disabled(fn (?Page $record): bool => $record?->isHome() ?? false)
->dehydrated()
->unique(ignoreRecord: true, modifyRuleUsing: fn (Unique $rule, callable $get) => $rule->where('site_id', $get('site_id'))),
TextInput::make('menu_label')->label('Name im Menü (optional)')->maxLength(60),
Select::make('menu_location')->label('Menü')->options(Page::MENU_LOCATIONS)->default('main')->required(),
Toggle::make('is_published')->label('Veröffentlicht')->default(true),
]),
Section::make('Suchmaschinen')
->columnSpan(1)
->collapsed()
->schema([
TextInput::make('seo_title')->label('Seitentitel (Google)')->maxLength(70),
Textarea::make('seo_description')->label('Beschreibung (Google)')->rows(3)->maxLength(170),
]),
]);
}
}