108 lines
5.0 KiB
PHP
108 lines
5.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Monitoring\ContentRecaps\Schemas;
|
|
|
|
use App\Enums\Channel;
|
|
use App\Enums\ContentType;
|
|
use App\Enums\NotifStyle;
|
|
use App\Enums\SocialMedia;
|
|
use App\Filament\Support\CheerfulNotification;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Components\Grid;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class ContentRecapForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make(fn () => CheerfulNotification::getByKey('content.section_title'))
|
|
->description(fn () => CheerfulNotification::getByKey('content.section_desc'))
|
|
->icon(fn () => CheerfulNotification::getNotifStyle() === NotifStyle::CHEERFUL ? 'heroicon-o-document-text' : null)
|
|
->schema([
|
|
TextInput::make('title')
|
|
->label('Judul Konten')
|
|
->placeholder('Reels Kerja Sama DPMPTSP')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->maxLength(1000),
|
|
|
|
TextInput::make('link')
|
|
->label('Tautan (URL)')
|
|
->placeholder('https://www.pwknews.com')
|
|
->autocomplete(false)
|
|
->nullable()
|
|
->maxLength(255)
|
|
->url(),
|
|
|
|
Grid::make(2)
|
|
->schema([
|
|
Select::make('type')
|
|
->label('Tipe Konten')
|
|
->options(ContentType::options())
|
|
->native(false)
|
|
->required()
|
|
->in(implode(',', array_column(ContentType::cases(), 'value'))),
|
|
|
|
Select::make('channel')
|
|
->label('Kanal')
|
|
->options(Channel::options())
|
|
->native(false)
|
|
->required()
|
|
->in(implode(',', array_column(Channel::cases(), 'value'))),
|
|
|
|
Select::make('social_media')
|
|
->label('Media Sosial')
|
|
->options(SocialMedia::options())
|
|
->native(false)
|
|
->required()
|
|
->in(implode(',', array_column(SocialMedia::cases(), 'value'))),
|
|
|
|
DatePicker::make('posting_date')
|
|
->label('Tanggal Posting')
|
|
->placeholder(fn (): string => now()->translatedFormat('l, d F Y'))
|
|
->native(false)
|
|
->displayFormat('l, d F Y')
|
|
->required(),
|
|
]),
|
|
])->columnSpan(2),
|
|
|
|
Section::make(fn () => CheerfulNotification::getByKey('content.attachment_title'))
|
|
->description(fn () => CheerfulNotification::getByKey('content.attachment_desc'))
|
|
->icon(fn () => CheerfulNotification::getNotifStyle() === NotifStyle::CHEERFUL ? 'heroicon-o-folder-open' : null)
|
|
->schema([
|
|
Select::make('classification_id')
|
|
->label('Klasifikasi')
|
|
->relationship('classification', 'name', function (Builder $query): Builder {
|
|
return $query->active();
|
|
})
|
|
->native(false)
|
|
->preload()
|
|
->required(),
|
|
|
|
SpatieMediaLibraryFileUpload::make('image')
|
|
->label('Gambar Konten')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['image/*'])
|
|
->maxSize(1024 * 3)
|
|
->collection('content-recaps')
|
|
->customProperties(fn (): array => [
|
|
'feature' => 'content-recaps',
|
|
'date' => now()->toDateString(),
|
|
])
|
|
->image()
|
|
->helperText('Format yang diterima: JPEG, PNG, GIF, WEBP. Ukuran maksimum: 3 MB.')
|
|
->required(),
|
|
])->columnSpan(1),
|
|
])
|
|
->columns(3);
|
|
}
|
|
}
|