first commit
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user