From ad0cf1a53558fdd4b07d71b332f07197ebbfcced Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sat, 7 Mar 2026 13:20:06 +0700 Subject: [PATCH] style: Standardize anonymous function syntax and minor whitespace in Filament resources. --- .../DelayedGoods/Schemas/DelayedGoodForm.php | 6 +++--- .../DelayedGoods/Tables/DelayedGoodsTable.php | 18 +++++++++--------- .../EggCollections/EggCollectionResource.php | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php b/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php index 1e645dd..0dc17e9 100644 --- a/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php +++ b/app/Filament/Resources/DelayedGoods/Schemas/DelayedGoodForm.php @@ -93,7 +93,7 @@ public static function configure(Schema $schema): Schema $recalculateRemaining($get, $set); }) ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 2) - ->formatStateUsing(fn($state) => $state === null ? null : (float) $state) + ->formatStateUsing(fn ($state) => $state === null ? null : (float) $state) ->dehydrateStateUsing($unmaskQty), TextInput::make('unit_price') @@ -129,7 +129,7 @@ public static function configure(Schema $schema): Schema ->required() ->live() ->formatStateUsing( - fn($state) => number_format((float) ($state ?? 0), 0, ',', '.') + fn ($state) => number_format((float) ($state ?? 0), 0, ',', '.') ) ->dehydrateStateUsing($unmaskMoney), @@ -141,7 +141,7 @@ public static function configure(Schema $schema): Schema ->required() ->live() ->prefix('Rp') - ->readOnly(fn(callable $get) => $get('is_paid')) + ->readOnly(fn (callable $get) => $get('is_paid')) ->afterStateUpdated(function ($state, callable $get, callable $set) use ($recalculateRemaining, $unmaskMoney): void { $paidAmount = $unmaskMoney($state); $totalAmount = $unmaskMoney($get('total_amount')); diff --git a/app/Filament/Resources/DelayedGoods/Tables/DelayedGoodsTable.php b/app/Filament/Resources/DelayedGoods/Tables/DelayedGoodsTable.php index c84852b..20102db 100644 --- a/app/Filament/Resources/DelayedGoods/Tables/DelayedGoodsTable.php +++ b/app/Filament/Resources/DelayedGoods/Tables/DelayedGoodsTable.php @@ -37,7 +37,7 @@ public static function configure(Table $table): Table TextColumn::make('quantity') ->label('Jumlah') ->getStateUsing(function ($record) { - return str_replace('.', ',', (float) $record->quantity) . " {$record->unit?->alias}"; + return str_replace('.', ',', (float) $record->quantity)." {$record->unit?->alias}"; }) ->sortable(), @@ -55,14 +55,14 @@ public static function configure(Table $table): Table ->label('Sudah Dibayar') ->money('IDR', decimalPlaces: 0) ->sortable() - ->color(fn($record) => $record->paid_amount >= $record->total_amount ? 'success' : 'warning'), + ->color(fn ($record) => $record->paid_amount >= $record->total_amount ? 'success' : 'warning'), TextColumn::make('remaining_amount') ->label('Sisa') - ->getStateUsing(fn($record) => max(0, $record->total_amount - $record->paid_amount)) + ->getStateUsing(fn ($record) => max(0, $record->total_amount - $record->paid_amount)) ->money('IDR', decimalPlaces: 0) ->sortable() - ->color(fn($record) => $record->paid_amount >= $record->total_amount ? 'success' : 'danger'), + ->color(fn ($record) => $record->paid_amount >= $record->total_amount ? 'success' : 'danger'), IconColumn::make('is_paid') ->label('Status') @@ -87,24 +87,24 @@ public static function configure(Table $table): Table ->filters([ TrashedFilter::make() ->native(false) - ->visible(fn(): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), + ->visible(fn (): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), ]) ->recordActions([ Action::make('pelunasan') ->label('Pelunasan') ->icon(Heroicon::CurrencyDollar) ->color('success') - ->visible(fn($record) => ! $record->is_paid) + ->visible(fn ($record) => ! $record->is_paid) ->schema([ TextInput::make('amount') ->label('Jumlah yang dibayar') ->required() - ->default(fn($record) => max(0, $record->total_amount - $record->paid_amount)) - ->helperText(fn($record) => 'sisa: Rp ' . number_format(max(0, $record->total_amount - $record->paid_amount), 0, ',', '.')) + ->default(fn ($record) => max(0, $record->total_amount - $record->paid_amount)) + ->helperText(fn ($record) => 'sisa: Rp '.number_format(max(0, $record->total_amount - $record->paid_amount), 0, ',', '.')) ->prefix('Rp') ->live() ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) - ->dehydrateStateUsing(fn($state) => (float) str()->replace(',', '.', str()->replace('.', '', (string) ($state ?? 0)))), + ->dehydrateStateUsing(fn ($state) => (float) str()->replace(',', '.', str()->replace('.', '', (string) ($state ?? 0)))), ]) ->requiresConfirmation() ->action(function (array $data, $record) { diff --git a/app/Filament/Resources/Manage/EggCollections/EggCollectionResource.php b/app/Filament/Resources/Manage/EggCollections/EggCollectionResource.php index b721280..dc1f3d3 100644 --- a/app/Filament/Resources/Manage/EggCollections/EggCollectionResource.php +++ b/app/Filament/Resources/Manage/EggCollections/EggCollectionResource.php @@ -58,7 +58,7 @@ public static function form(Schema $schema): Schema ->required() ->searchable() ->preload() - ->default(fn() => Warehouse::first()?->id), + ->default(fn () => Warehouse::first()?->id), Repeater::make('items') ->label('Rincian Produksi') @@ -77,7 +77,7 @@ public static function form(Schema $schema): Schema ->autocomplete(false) ->required() ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 2) - ->formatStateUsing(fn($state) => $state === null ? null : (float) $state) + ->formatStateUsing(fn ($state) => $state === null ? null : (float) $state) ->dehydrateStateUsing(function ($state) { if (blank($state)) { return 0; @@ -131,11 +131,11 @@ public static function table(Table $table): Table ->orderBy('is_broken') ->with('unit') ->get() - ->map(fn($item) => str_replace('.', ',', (float) $item->quantity) . " {$item->unit?->alias}" . ($item->is_broken ? ' (Pecah)' : '')) + ->map(fn ($item) => str_replace('.', ',', (float) $item->quantity)." {$item->unit?->alias}".($item->is_broken ? ' (Pecah)' : '')) ->toArray(); }) ->listWithLineBreaks() - ->color(fn($state) => str_contains($state, '(Pecah)') ? 'danger' : 'success') + ->color(fn ($state) => str_contains($state, '(Pecah)') ? 'danger' : 'success') ->placeholder('-'), TextColumn::make('notes') @@ -148,13 +148,13 @@ public static function table(Table $table): Table ->filters([ TrashedFilter::make() ->native(false) - ->visible(fn(): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), + ->visible(fn (): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), ]) ->recordActions([ EditAction::make() ->label('Ubah') ->modalWidth(Width::FourExtraLarge) - ->modalHeading(fn(EggCollection $record): string => 'Ubah ' . $record->production_date->translatedFormat('l, d F Y H:i')), + ->modalHeading(fn (EggCollection $record): string => 'Ubah '.$record->production_date->translatedFormat('l, d F Y H:i')), DeleteAction::make(),