components([ Hidden::make('production_date') ->default(now()), TextInput::make('total_eggs') ->label('Jumlah Telur') ->placeholder('0') ->autocomplete(false) ->required() ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) ->dehydrateStateUsing(fn ($state) => (int) str()->replace(',', '', (string) ($state ?? 0))), TextInput::make('total_broken_eggs') ->label('Jumlah Telur Pecah') ->placeholder('0') ->autocomplete(false) ->required() ->currencyMask(thousandSeparator: '.', decimalSeparator: ',', precision: 0) ->dehydrateStateUsing(fn ($state) => (int) str()->replace(',', '', (string) ($state ?? 0))), Textarea::make('notes') ->label('Catatan') ->placeholder('...') ->columnSpanFull(), ]) ->columns(1); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('production_date') ->label('Tanggal Produksi') ->dateTime('l, d F Y H:i') ->searchable() ->sortable(), TextColumn::make('total_eggs') ->label('Total Telur') ->numeric() ->searchable() ->sortable(), TextColumn::make('total_broken_eggs') ->label('Total Telur Pecah') ->numeric() ->searchable() ->sortable(), TextColumn::make('notes') ->label('Catatan') ->searchable() ->wrap() ->toggleable(), ...TimestampColumns::make(), ]) ->filters([ TrashedFilter::make() ->native(false) ->visible(fn (): bool => auth()->user()->hasRole(RoleEnum::DEVELOPER)), ]) ->recordActions([ EditAction::make() ->label('Ubah') ->modalWidth(Width::Large) ->modalHeading(fn (EggCollection $record): string => 'Ubah '.$record->production_date->translatedFormat('l, d F Y H:i')), DeleteAction::make(), ForceDeleteAction::make(), RestoreAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ ...DefaultBulkActions::make('Produksi Telur'), ]), ]) ->emptyStateIcon(Heroicon::RectangleGroup) ->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.') ->defaultSort('created_at', 'desc') ->deferFilters(false); } public static function getPages(): array { return [ 'index' => ManageEggCollections::route('/'), ]; } }