refactor: Reorder static properties and adjust function syntax in Filament resources and pages for consistency.

This commit is contained in:
Yoga Pangestu 2026-01-27 20:47:04 +07:00
parent 337238b518
commit 3f0529a53e
16 changed files with 58 additions and 60 deletions

View File

@ -27,18 +27,18 @@ class AdminVerification extends Page implements HasActions, HasForms
{ {
use HasPageShield, InteractsWithActions, InteractsWithForms; use HasPageShield, InteractsWithActions, InteractsWithForms;
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
protected static ?string $title = 'Verifikasi Rekanan';
protected static string|UnitEnum|null $navigationGroup = 'Kelola'; protected static string|UnitEnum|null $navigationGroup = 'Kelola';
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
protected static ?string $navigationLabel = 'Verifikasi Rekanan'; protected static ?string $navigationLabel = 'Verifikasi Rekanan';
protected static ?int $navigationSort = 2; protected static ?int $navigationSort = 2;
protected static ?string $slug = 'manage/admin-verification'; protected static ?string $slug = 'manage/admin-verification';
protected static ?string $title = 'Verifikasi Rekanan';
protected string $view = 'filament.pages.admin-verification'; protected string $view = 'filament.pages.admin-verification';
public string $filterStatus = 'all'; public string $filterStatus = 'all';

View File

@ -19,16 +19,16 @@ class ManageGeneralSettings extends SettingsPage
{ {
use HasPageShield; use HasPageShield;
protected static string|BackedEnum|null $navigationIcon = Heroicon::Cog6Tooth;
protected static string $settings = GeneralSettings::class;
protected static string|UnitEnum|null $navigationGroup = 'Pengaturan'; protected static string|UnitEnum|null $navigationGroup = 'Pengaturan';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Cog6Tooth;
protected static ?string $navigationLabel = 'Umum'; protected static ?string $navigationLabel = 'Umum';
protected static ?int $navigationSort = 1; protected static ?int $navigationSort = 1;
protected static string $settings = GeneralSettings::class;
protected static ?string $title = 'Pengaturan Umum'; protected static ?string $title = 'Pengaturan Umum';
public function form(Schema $schema): Schema public function form(Schema $schema): Schema

View File

@ -17,16 +17,16 @@ class ManageSeoSettings extends SettingsPage
{ {
use HasPageShield; use HasPageShield;
protected static string|BackedEnum|null $navigationIcon = Heroicon::MagnifyingGlass;
protected static string $settings = SeoSettings::class;
protected static string|UnitEnum|null $navigationGroup = 'Pengaturan'; protected static string|UnitEnum|null $navigationGroup = 'Pengaturan';
protected static string|BackedEnum|null $navigationIcon = Heroicon::MagnifyingGlass;
protected static ?string $navigationLabel = 'SEO'; protected static ?string $navigationLabel = 'SEO';
protected static ?int $navigationSort = 3; protected static ?int $navigationSort = 3;
protected static string $settings = SeoSettings::class;
protected static ?string $title = 'Pengaturan SEO'; protected static ?string $title = 'Pengaturan SEO';
public function form(Schema $schema): Schema public function form(Schema $schema): Schema

View File

@ -17,16 +17,16 @@ class ManageSocialMediaSettings extends SettingsPage
{ {
use HasPageShield; use HasPageShield;
protected static string|BackedEnum|null $navigationIcon = Heroicon::Share;
protected static string $settings = SocialMediaSettings::class;
protected static string|UnitEnum|null $navigationGroup = 'Pengaturan'; protected static string|UnitEnum|null $navigationGroup = 'Pengaturan';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Share;
protected static ?string $navigationLabel = 'Media Sosial'; protected static ?string $navigationLabel = 'Media Sosial';
protected static ?int $navigationSort = 2; protected static ?int $navigationSort = 2;
protected static string $settings = SocialMediaSettings::class;
protected static ?string $title = 'Pengaturan Media Sosial'; protected static ?string $title = 'Pengaturan Media Sosial';
public function form(Schema $schema): Schema public function form(Schema $schema): Schema

View File

@ -29,18 +29,18 @@ class ContactResource extends Resource
{ {
protected static ?string $model = Contact::class; protected static ?string $model = Contact::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::Envelope; protected static ?string $modelLabel = 'Kontak';
protected static string|UnitEnum|null $navigationGroup = 'Kelola'; protected static string|UnitEnum|null $navigationGroup = 'Kelola';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Envelope;
protected static ?string $navigationLabel = 'Kontak'; protected static ?string $navigationLabel = 'Kontak';
protected static ?int $navigationSort = 8; protected static ?int $navigationSort = 8;
protected static ?string $recordTitleAttribute = 'subject'; protected static ?string $recordTitleAttribute = 'subject';
protected static ?string $modelLabel = 'Kontak';
protected static ?string $slug = 'manage/contacts'; protected static ?string $slug = 'manage/contacts';
public static function getNavigationBadge(): ?string public static function getNavigationBadge(): ?string
@ -104,7 +104,7 @@ public static function infolist(Schema $schema): Schema
->placeholder('Belum dibalas'), ->placeholder('Belum dibalas'),
]) ])
->columnSpanFull() ->columnSpanFull()
->visible(fn (Contact $record): bool => $record->replied_at !== null), ->visible(fn(Contact $record): bool => $record->replied_at !== null),
]) ])
->columns(2); ->columns(2);
} }
@ -128,7 +128,7 @@ public static function table(Table $table): Table
IconColumn::make('replied_at') IconColumn::make('replied_at')
->label('Dibalas') ->label('Dibalas')
->boolean() ->boolean()
->getStateUsing(fn (Contact $record): bool => $record->replied_at !== null), ->getStateUsing(fn(Contact $record): bool => $record->replied_at !== null),
TextColumn::make('repliedBy.name') TextColumn::make('repliedBy.name')
->label('Dibalas Oleh') ->label('Dibalas Oleh')
@ -157,7 +157,7 @@ public static function table(Table $table): Table
->schema([ ->schema([
Textarea::make('reply_message') Textarea::make('reply_message')
->label('Pesan Balasan') ->label('Pesan Balasan')
->placeholder(fn (Contact $record): string => "Halo {$record->name}, ...") ->placeholder(fn(Contact $record): string => "Halo {$record->name}, ...")
->required() ->required()
->rows(5) ->rows(5)
->autocomplete(false) ->autocomplete(false)
@ -177,7 +177,7 @@ public static function table(Table $table): Table
'Pesan balasan Anda sudah meluncur ke email pengirim. Semoga membantu mereka ya! 😊' 'Pesan balasan Anda sudah meluncur ke email pengirim. Semoga membantu mereka ya! 😊'
)->send(); )->send();
}) })
->visible(fn (Contact $record): bool => $record->replied_at === null), ->visible(fn(Contact $record): bool => $record->replied_at === null),
DeleteAction::make() DeleteAction::make()
->label('Hapus'), ->label('Hapus'),

View File

@ -13,10 +13,10 @@
class ManageJournalists extends ManageRecords class ManageJournalists extends ManageRecords
{ {
protected static ?string $title = 'Jurnalis';
protected static string $resource = JournalistResource::class; protected static string $resource = JournalistResource::class;
protected static ?string $title = 'Jurnalis';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
if (auth()->user()->hasRole(RoleEnum::PERUSAHAAN->value) && ! auth()->user()->company?->partnerMedia) { if (auth()->user()->hasRole(RoleEnum::PERUSAHAAN->value) && ! auth()->user()->company?->partnerMedia) {
@ -37,7 +37,7 @@ protected function getHeaderActions(): array
->modalHeading('Tambah Jurnalis') ->modalHeading('Tambah Jurnalis')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->modalCancelActionLabel('Batal') ->modalCancelActionLabel('Batal')
->extraModalFooterActions(fn (CreateAction $action): array => [ ->extraModalFooterActions(fn(CreateAction $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])

View File

@ -7,7 +7,7 @@
class ManagePartners extends ManageRecords class ManagePartners extends ManageRecords
{ {
protected static ?string $title = 'Rekanan';
protected static string $resource = PartnerResource::class; protected static string $resource = PartnerResource::class;
protected static ?string $title = 'Rekanan';
} }

View File

@ -9,10 +9,10 @@
class ManageClassifications extends ManageRecords class ManageClassifications extends ManageRecords
{ {
protected static ?string $title = 'Klasifikasi';
protected static string $resource = ClassificationResource::class; protected static string $resource = ClassificationResource::class;
protected static ?string $title = 'Klasifikasi';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [

View File

@ -9,10 +9,10 @@
class ManageDepartments extends ManageRecords class ManageDepartments extends ManageRecords
{ {
protected static ?string $title = 'OPD';
protected static string $resource = DepartmentResource::class; protected static string $resource = DepartmentResource::class;
protected static ?string $title = 'OPD';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -21,7 +21,7 @@ protected function getHeaderActions(): array
->modalHeading('Tambah OPD') ->modalHeading('Tambah OPD')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->modalCancelActionLabel('Batal') ->modalCancelActionLabel('Batal')
->extraModalFooterActions(fn (CreateAction $action): array => [ ->extraModalFooterActions(fn(CreateAction $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])

View File

@ -9,10 +9,10 @@
class ManageLocations extends ManageRecords class ManageLocations extends ManageRecords
{ {
protected static ?string $title = 'Lokasi';
protected static string $resource = LocationResource::class; protected static string $resource = LocationResource::class;
protected static ?string $title = 'Lokasi';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -21,7 +21,7 @@ protected function getHeaderActions(): array
->modalHeading('Tambah Lokasi') ->modalHeading('Tambah Lokasi')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->modalCancelActionLabel('Batal') ->modalCancelActionLabel('Batal')
->extraModalFooterActions(fn (CreateAction $action): array => [ ->extraModalFooterActions(fn(CreateAction $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])

View File

@ -9,10 +9,10 @@
class ManageThemes extends ManageRecords class ManageThemes extends ManageRecords
{ {
protected static ?string $title = 'Tema';
protected static string $resource = ThemeResource::class; protected static string $resource = ThemeResource::class;
protected static ?string $title = 'Tema';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -21,7 +21,7 @@ protected function getHeaderActions(): array
->modalHeading('Tambah Tema') ->modalHeading('Tambah Tema')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->modalCancelActionLabel('Batal') ->modalCancelActionLabel('Batal')
->extraModalFooterActions(fn (CreateAction $action): array => [ ->extraModalFooterActions(fn(CreateAction $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])

View File

@ -46,8 +46,6 @@ class UserResource extends Resource
protected static ?int $navigationSort = 8; protected static ?int $navigationSort = 8;
// protected static ?string $recordTitleAttribute = 'name';
protected static ?string $slug = 'master/users'; protected static ?string $slug = 'master/users';
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema

View File

@ -34,18 +34,18 @@ class AnnouncementResource extends Resource
{ {
protected static ?string $model = Announcement::class; protected static ?string $model = Announcement::class;
protected static string|UnitEnum|null $navigationGroup = 'Publikasi';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Megaphone; protected static string|BackedEnum|null $navigationIcon = Heroicon::Megaphone;
protected static ?string $navigationLabel = 'Pengumuman'; protected static ?string $navigationLabel = 'Pengumuman';
protected static string|UnitEnum|null $navigationGroup = 'Publikasi';
protected static ?int $navigationSort = 2; protected static ?int $navigationSort = 2;
protected static ?string $slug = 'publication/announcements';
protected static ?string $recordTitleAttribute = 'title'; protected static ?string $recordTitleAttribute = 'title';
protected static ?string $slug = 'publication/announcements';
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema
{ {
return $schema return $schema
@ -75,16 +75,16 @@ public static function form(Schema $schema): Schema
CheckboxList::make('partnerMedia') CheckboxList::make('partnerMedia')
->label('Kirim Kepada') ->label('Kirim Kepada')
->relationship('partnerMedia', 'name', fn (Builder $query): Builder => $query->verified()) ->relationship('partnerMedia', 'name', fn(Builder $query): Builder => $query->verified())
->visible(fn (Get $get): bool => in_array($get('type'), [AnnouncementType::COMPANY, AnnouncementType::COMPANY->value])) ->visible(fn(Get $get): bool => in_array($get('type'), [AnnouncementType::COMPANY, AnnouncementType::COMPANY->value]))
->required(fn (Get $get): bool => in_array($get('type'), [AnnouncementType::COMPANY, AnnouncementType::COMPANY->value])) ->required(fn(Get $get): bool => in_array($get('type'), [AnnouncementType::COMPANY, AnnouncementType::COMPANY->value]))
->searchable() ->searchable()
->noSearchResultsMessage('Tidak ada media yang ditemukan.') ->noSearchResultsMessage('Tidak ada media yang ditemukan.')
->helperText('Pilih media yang akan menerima pengumuman ini') ->helperText('Pilih media yang akan menerima pengumuman ini')
->columnSpanFull() ->columnSpanFull()
->bulkToggleable() ->bulkToggleable()
->selectAllAction( ->selectAllAction(
fn (Action $action): Action => $action->label('Pilih Semua Media'), fn(Action $action): Action => $action->label('Pilih Semua Media'),
) )
->dehydrated(), ->dehydrated(),
@ -121,7 +121,7 @@ public static function table(Table $table): Table
->listWithLineBreaks() ->listWithLineBreaks()
->limitList(3) ->limitList(3)
->expandableLimitedList() ->expandableLimitedList()
->placeholder(fn (Announcement $record): string => $record->type === AnnouncementType::PUBLIC ? 'Publik' : 'Tidak ada penerima'), ->placeholder(fn(Announcement $record): string => $record->type === AnnouncementType::PUBLIC ? 'Publik' : 'Tidak ada penerima'),
...TimestampColumns::make(), ...TimestampColumns::make(),
]) ])
@ -131,7 +131,7 @@ public static function table(Table $table): Table
->recordActions([ ->recordActions([
EditAction::make() EditAction::make()
->modalWidth(Width::TwoExtraLarge) ->modalWidth(Width::TwoExtraLarge)
->visible(fn (Announcement $record): bool => $record->type === AnnouncementType::PUBLIC), ->visible(fn(Announcement $record): bool => $record->type === AnnouncementType::PUBLIC),
DeleteAction::make(), DeleteAction::make(),

View File

@ -14,10 +14,10 @@
class ManageAnnouncements extends ManageRecords class ManageAnnouncements extends ManageRecords
{ {
protected static ?string $title = 'Pengumuman';
protected static string $resource = AnnouncementResource::class; protected static string $resource = AnnouncementResource::class;
protected static ?string $title = 'Pengumuman';
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -26,7 +26,7 @@ protected function getHeaderActions(): array
->modalHeading('Tambah Pengumuman') ->modalHeading('Tambah Pengumuman')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->modalCancelActionLabel('Batal') ->modalCancelActionLabel('Batal')
->extraModalFooterActions(fn (CreateAction $action): array => [ ->extraModalFooterActions(fn(CreateAction $action): array => [
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true]) $action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Simpan dan Tambah Lagi'), ->label('Simpan dan Tambah Lagi'),
]) ])

View File

@ -21,18 +21,18 @@ class NewsResource extends Resource
{ {
protected static ?string $model = News::class; protected static ?string $model = News::class;
protected static string|UnitEnum|null $navigationGroup = 'Publikasi';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Newspaper; protected static string|BackedEnum|null $navigationIcon = Heroicon::Newspaper;
protected static ?string $navigationLabel = 'Berita'; protected static ?string $navigationLabel = 'Berita';
protected static string|UnitEnum|null $navigationGroup = 'Publikasi';
protected static ?int $navigationSort = 1; protected static ?int $navigationSort = 1;
protected static ?string $slug = 'publication/news';
protected static ?string $recordTitleAttribute = 'title'; protected static ?string $recordTitleAttribute = 'title';
protected static ?string $slug = 'publication/news';
public static function form(Schema $schema): Schema public static function form(Schema $schema): Schema
{ {
return NewsForm::configure($schema); return NewsForm::configure($schema);

View File

@ -7,7 +7,7 @@
class ManageVisitors extends ManageRecords class ManageVisitors extends ManageRecords
{ {
protected static ?string $title = 'Pengunjung';
protected static string $resource = VisitorResource::class; protected static string $resource = VisitorResource::class;
protected static ?string $title = 'Pengunjung';
} }