columns(3) ->components([ Hidden::make('user_id') ->default(fn () => user()->id), TextInput::make('number') ->label(__('Card number')) ->mask('9999 9999 9999 9999') ->dehydrateStateUsing(fn ($state) => str_replace(' ', '', $state)) ->columnSpan(1) ->required(), Select::make('month') ->label(__('Card month')) ->options(DateHelper::staticNumberMonths()) ->native(false) ->columnSpan(1) ->required(), Select::make('year') ->label(__('Card year')) ->options(DateHelper::staticNumberYears()) ->native(false) ->columnSpan(1) ->required(), TextInput::make('name') ->label(__('Card name')) ->maxLength(255) ->columnSpanFull() ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('number') ->label(__('Card number')) ->formatStateUsing(fn ($state) => trim(chunk_split($state, 4, ' '))) ->searchable(), TextColumn::make('name') ->label(__('Card name')) ->searchable(), TextColumn::make('month') ->label(__('Card month')) ->searchable(), TextColumn::make('year') ->label(__('Card year')) ->searchable(), TextColumn::make('created_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), TextColumn::make('updated_at') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ // ]) ->recordActions([ Action::make('card_balance') ->label(__('Card balance')) ->icon('heroicon-o-credit-card') ->requiresConfirmation(false) ->modal() ->modalContent(fn (Card $record): View => CardBalanceRepository::make()->showCardBalance($record)) ->modalFooterActions([]), Action::make('card_transactions') ->label(__('Card transactions')) ->icon('heroicon-o-arrows-right-left') ->requiresConfirmation() ->modalIcon('heroicon-m-arrows-right-left') ->schema([ DatePicker::make('start_date') ->label(__('Start date')) ->native(false) ->required() ->beforeOrEqual('today'), DatePicker::make('end_date') ->label(__('End date')) ->native(false) ->required() ->beforeOrEqual('today'), ]) ->action( fn (array $data, Card $record, Component $livewire) => CardTransactionRepository::make()->downloadCardTransaction($data, $record, $livewire) ), Action::make('card_requisite') ->label(__('Card requisite')) ->icon('heroicon-o-document-text') ->requiresConfirmation() ->modalIcon('heroicon-o-document-text') ->action(fn (Card $record, Component $livewire) => CardRequisiteRepository::make()->downloadCardRequisite($record, $livewire)), EditAction::make() ->label(''), DeleteAction::make() ->label(''), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]); } public static function getPages(): array { return [ 'index' => ManageCards::route('/'), ]; } }