42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Filament\Resources\Posts\Schemas;
|
||
|
|
|
||
|
|
use Filament\Forms\Components\DateTimePicker;
|
||
|
|
use Filament\Forms\Components\FileUpload;
|
||
|
|
use Filament\Forms\Components\RichEditor;
|
||
|
|
use Filament\Forms\Components\TagsInput;
|
||
|
|
use Filament\Forms\Components\TextInput;
|
||
|
|
use Filament\Forms\Components\Textarea;
|
||
|
|
use Filament\Schemas\Schema;
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class PostForm
|
||
|
|
{
|
||
|
|
public static function configure(Schema $schema): Schema
|
||
|
|
{
|
||
|
|
return $schema
|
||
|
|
->components([
|
||
|
|
TextInput::make('title')
|
||
|
|
->required()
|
||
|
|
->live(onBlur: true)
|
||
|
|
->afterStateUpdated(fn ($state, callable $set) => $set('slug', Str::slug($state))),
|
||
|
|
TextInput::make('slug')
|
||
|
|
->required()
|
||
|
|
->unique(ignoreRecord: true),
|
||
|
|
Textarea::make('excerpt')
|
||
|
|
->columnSpanFull(),
|
||
|
|
RichEditor::make('body')
|
||
|
|
->columnSpanFull(),
|
||
|
|
FileUpload::make('cover_image')
|
||
|
|
->image()
|
||
|
|
->disk('public')
|
||
|
|
->directory('posts'),
|
||
|
|
TagsInput::make('tags')
|
||
|
|
->columnSpanFull(),
|
||
|
|
DateTimePicker::make('published_at')
|
||
|
|
->helperText('Leave blank to keep this post as a draft.'),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|