style: Standardize anonymous function syntax and minor whitespace in Filament resources.
This commit is contained in:
parent
49387e7923
commit
ad0cf1a535
@ -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'));
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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(),
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user