- Refactor custom Filament actions into resource-specific subfolders (Cooperation, Proposal, Report).
- Standardize all action identifiers to snake_case for consistency.
- Move action identifiers directly into ::make('name') calls.
- Remove getDefaultName() from custom action classes to favor explicit naming.
- Update relation managers and resources to use the new namespaced action classes.
- Standardize closure syntax (fn) and string formatting across schemas and actions.
107 lines
4.4 KiB
PHP
107 lines
4.4 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\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class CooperationForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make([
|
|
TextInput::make('title')
|
|
->label('Judul')
|
|
->placeholder('Publikasi Pembangunan Daerah')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->maxLength(200),
|
|
|
|
Grid::make(2)
|
|
->schema([
|
|
DatePicker::make('initial_submission_date')
|
|
->label('Tanggal Pengajuan Awal')
|
|
->placeholder(fn () => now()->format('Y-m-d'))
|
|
->native(false)
|
|
->displayFormat('l, d F Y')
|
|
->required(),
|
|
|
|
DatePicker::make('final_submission_date')
|
|
->label('Tanggal Pengajuan Akhir')
|
|
->placeholder(fn () => now()->addDays(30)->format('Y-m-d'))
|
|
->native(false)
|
|
->displayFormat('l, d F Y')
|
|
->required()
|
|
->after('initial_submission_date'),
|
|
]),
|
|
|
|
Select::make('partner_media_ids')
|
|
->label('Media')
|
|
->relationship('partnerMedia', 'name', fn (Builder $query) => $query->verified())
|
|
->multiple()
|
|
->preload()
|
|
->searchable()
|
|
->native(false)
|
|
->required()
|
|
->selectablePlaceholder(false)
|
|
->helperText('Pilih media yang akan diajak kerja sama.')
|
|
->suffixAction(
|
|
Action::make('select_all')
|
|
->label('Select All')
|
|
->icon(Heroicon::OutlinedCheckCircle)
|
|
->action(function ($set, $livewire) {
|
|
$allMediaIds = PartnerMedia::verified()->pluck('id')->toArray();
|
|
$set('partner_media_ids', $allMediaIds);
|
|
})
|
|
),
|
|
|
|
Textarea::make('description')
|
|
->label('Deskripsi')
|
|
->placeholder('...')
|
|
->required()
|
|
->rows(5)
|
|
->maxLength(65535),
|
|
])
|
|
->columnSpan(2),
|
|
|
|
Section::make([
|
|
SpatieMediaLibraryFileUpload::make('banner')
|
|
->label('Banner')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['image/*'])
|
|
->maxSize(1024 * 3)
|
|
->collection('cooperations')
|
|
->customProperties(fn () => [
|
|
'feature' => 'cooperations',
|
|
'doc_type' => 'banner',
|
|
'date' => now()->toDateString(),
|
|
])
|
|
->image(),
|
|
|
|
AdvancedFileUpload::make('proposal_template')
|
|
->label('Template Pengajuan')
|
|
->disk(config('filesystems.default'))
|
|
->acceptedFileTypes(['application/pdf'])
|
|
->maxSize(1024 * 10)
|
|
->directory(fn () => 'cooperations/proposal-template/'.now()->toDateString())
|
|
->required(),
|
|
]),
|
|
])
|
|
->columns(3);
|
|
}
|
|
}
|