67 lines
2.3 KiB
PHP
67 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Publication\News\Schemas;
|
|
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
|
use Filament\Forms\Components\TagsInput;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class NewsForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make([
|
|
TextInput::make('title')
|
|
->label('Judul')
|
|
->placeholder('Berita Purwakarta Hari Ini')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->maxLength(200),
|
|
|
|
RichEditor::make('content')
|
|
->label('Konten')
|
|
->placeholder('...')
|
|
->required()
|
|
->columnSpanFull(),
|
|
|
|
TextInput::make('link')
|
|
->label('Tautan')
|
|
->placeholder('https://www.pwknews.com')
|
|
->autocomplete(false)
|
|
->nullable()
|
|
->maxLength(50)
|
|
->url(),
|
|
])->columnSpan(2),
|
|
|
|
Section::make([
|
|
TagsInput::make('tags')
|
|
->reactive()
|
|
->afterStateHydrated(function ($component, $state, $record) {
|
|
if (! $record) {
|
|
return;
|
|
}
|
|
$component->state(
|
|
$record->tags->pluck('name')->toArray()
|
|
);
|
|
}),
|
|
|
|
SpatieMediaLibraryFileUpload::make('thumbnail')
|
|
->label('Thumbnail')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['image/*'])
|
|
->maxSize(1024 * 3)
|
|
->collection('news')
|
|
->image()
|
|
->required(),
|
|
]),
|
|
])
|
|
->columns(3);
|
|
}
|
|
}
|