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;
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|BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
protected static ?string $navigationLabel = 'Verifikasi Rekanan';
protected static ?int $navigationSort = 2;
protected static ?string $slug = 'manage/admin-verification';
protected static ?string $title = 'Verifikasi Rekanan';
protected string $view = 'filament.pages.admin-verification';
public string $filterStatus = 'all';

View File

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

View File

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

View File

@ -17,16 +17,16 @@ class ManageSocialMediaSettings extends SettingsPage
{
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|BackedEnum|null $navigationIcon = Heroicon::Share;
protected static ?string $navigationLabel = 'Media Sosial';
protected static ?int $navigationSort = 2;
protected static string $settings = SocialMediaSettings::class;
protected static ?string $title = 'Pengaturan Media Sosial';
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|BackedEnum|null $navigationIcon = Heroicon::Envelope;
protected static ?string $modelLabel = 'Kontak';
protected static string|UnitEnum|null $navigationGroup = 'Kelola';
protected static string|BackedEnum|null $navigationIcon = Heroicon::Envelope;
protected static ?string $navigationLabel = 'Kontak';
protected static ?int $navigationSort = 8;
protected static ?string $recordTitleAttribute = 'subject';
protected static ?string $modelLabel = 'Kontak';
protected static ?string $slug = 'manage/contacts';
public static function getNavigationBadge(): ?string
@ -104,7 +104,7 @@ public static function infolist(Schema $schema): Schema
->placeholder('Belum dibalas'),
])
->columnSpanFull()
->visible(fn (Contact $record): bool => $record->replied_at !== null),
->visible(fn(Contact $record): bool => $record->replied_at !== null),
])
->columns(2);
}
@ -128,7 +128,7 @@ public static function table(Table $table): Table
IconColumn::make('replied_at')
->label('Dibalas')
->boolean()
->getStateUsing(fn (Contact $record): bool => $record->replied_at !== null),
->getStateUsing(fn(Contact $record): bool => $record->replied_at !== null),
TextColumn::make('repliedBy.name')
->label('Dibalas Oleh')
@ -157,7 +157,7 @@ public static function table(Table $table): Table
->schema([
Textarea::make('reply_message')
->label('Pesan Balasan')
->placeholder(fn (Contact $record): string => "Halo {$record->name}, ...")
->placeholder(fn(Contact $record): string => "Halo {$record->name}, ...")
->required()
->rows(5)
->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! 😊'
)->send();
})
->visible(fn (Contact $record): bool => $record->replied_at === null),
->visible(fn(Contact $record): bool => $record->replied_at === null),
DeleteAction::make()
->label('Hapus'),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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