118 lines
5.6 KiB
PHP
118 lines
5.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Manage\Cooperations\Schemas;
|
|
|
|
use App\Models\PartnerMedia;
|
|
use Asmit\FilamentUpload\Forms\Components\AdvancedFileUpload;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Components\Grid;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Components\Utilities\Set;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class CooperationForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make('Detail Kerja Sama 🤝')
|
|
->description('Lengkapi informasi mengenai judul, durasi, dan media yang terlibat.')
|
|
->icon('heroicon-o-hand-raised')
|
|
->schema([
|
|
TextInput::make('title')
|
|
->label('Judul Kerja Sama')
|
|
->placeholder('Publikasi Pembangunan Daerah')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->maxLength(200),
|
|
|
|
Grid::make(2)
|
|
->schema([
|
|
DatePicker::make('initial_submission_date')
|
|
->label('Tgl Pengajuan Awal')
|
|
->placeholder(fn (): string => now()->translatedFormat('l, d F Y'))
|
|
->native(false)
|
|
->displayFormat('l, d F Y')
|
|
->required()
|
|
->minDate(today())
|
|
->reactive(),
|
|
|
|
DatePicker::make('final_submission_date')
|
|
->label('Tgl Pengajuan Akhir')
|
|
->placeholder(fn (): string => now()->addDays(7)->translatedFormat('l, d F Y'))
|
|
->native(false)
|
|
->displayFormat('l, d F Y')
|
|
->required()
|
|
->afterOrEqual('initial_submission_date')
|
|
->minDate(fn (Get $get) => $get('initial_submission_date')),
|
|
]),
|
|
|
|
Select::make('partner_media_ids')
|
|
->label('Media Rekanan')
|
|
->relationship('partnerMedia', 'name', fn (Builder $query): Builder => $query->verified())
|
|
->multiple()
|
|
->preload()
|
|
->searchable()
|
|
->native(false)
|
|
->required()
|
|
->selectablePlaceholder(false)
|
|
->helperText('Pilih satu atau lebih media yang akan diajak kerja sama.')
|
|
->suffixAction(
|
|
Action::make('select_all')
|
|
->label('Pilih Semua')
|
|
->icon('heroicon-o-check-circle')
|
|
->action(function (Set $set): void {
|
|
$allMediaIds = PartnerMedia::verified()->pluck('id')->toArray();
|
|
$set('partner_media_ids', $allMediaIds);
|
|
})
|
|
),
|
|
|
|
Textarea::make('description')
|
|
->label('Deskripsi Kerja Sama')
|
|
->placeholder('Jelaskan detail lingkup kerja sama di sini...')
|
|
->required()
|
|
->rows(5)
|
|
->maxLength(65535)
|
|
->autocomplete(false),
|
|
])
|
|
->columnSpan(2),
|
|
|
|
Section::make('Lampiran & Media 🖼️')
|
|
->description('Unggah banner promosi dan template untuk pengajuan.')
|
|
->icon('heroicon-o-paper-clip')
|
|
->schema([
|
|
SpatieMediaLibraryFileUpload::make('banner')
|
|
->label('Banner Promosi')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['image/*'])
|
|
->maxSize(1024 * 3)
|
|
->collection('banner')
|
|
->customProperties(fn (): array => [
|
|
'feature' => 'cooperations',
|
|
'doc_type' => 'banner',
|
|
'date' => now()->toDateString(),
|
|
])
|
|
->image(),
|
|
|
|
AdvancedFileUpload::make('proposal_template')
|
|
->label('Template Pengajuan (PDF)')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['application/pdf'])
|
|
->maxSize(1024 * 10)
|
|
->directory(fn (): string => 'cooperations/proposal-template/'.now()->toDateString())
|
|
->required(),
|
|
])->columnSpan(1),
|
|
])
|
|
->columns(3);
|
|
}
|
|
}
|