Files
omg-wtf-ai/app/Filament/Resources/Pages/Schemas/PageForm.php
T

67 lines
2.6 KiB
PHP
Raw Normal View History

2026-08-08 18:03:29 +03:00
<?php
namespace App\Filament\Resources\Pages\Schemas;
use App\Models\Page;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class PageForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(3)
->components([
Section::make('Content')
->columnSpan(2)
->components([
TextInput::make('title')
->required()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, callable $set) {
if ($operation === 'create') {
$set('slug', Str::slug($state));
}
}),
TextInput::make('slug')
->required()
->unique(Page::class, 'slug', ignoreRecord: true)
->helperText('Used in the URL, e.g. /your-slug'),
MarkdownEditor::make('body')
->required()
->columnSpanFull(),
]),
Section::make('Visibility')
->columnSpan(1)
->components([
Toggle::make('published')
->default(true),
Toggle::make('show_in_footer')
->label('Show in footer')
->default(true),
TextInput::make('order')
->numeric()
->default(0)
->helperText('Lower numbers appear first in the footer.'),
]),
Section::make('SEO')
->description('Optional overrides for search engines and social sharing.')
->columnSpan(3)
->columns(2)
->collapsible()
->components([
TextInput::make('meta_title')
->maxLength(60)
->helperText('Falls back to the page title if left blank.'),
TextInput::make('meta_description')
->maxLength(160),
]),
]);
}
}