columns([ TextColumn::make('user.name') ->label('کاربر') ->searchable() ->sortable(), TextColumn::make('user.email') ->label('ایمیل') ->searchable() ->toggleable(), TextColumn::make('user.mobile') ->label('موبایل') ->searchable() ->toggleable(), TextColumn::make('balance') ->label('موجودی (تومان)') ->numeric() ->sortable() ->formatStateUsing(fn (int $state): string => number_format($state).' تومان'), IconColumn::make('is_active') ->label('فعال') ->boolean(), TextColumn::make('updated_at') ->label('آخرین بروزرسانی') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->defaultSort('balance', 'desc') ->filters([ TernaryFilter::make('is_active') ->label('وضعیت') ->placeholder('همه') ->trueLabel('فعال') ->falseLabel('غیرفعال'), ]) ->recordActions([ ViewAction::make(), EditAction::make(), self::adjustAction('credit', 'واریز', Heroicon::OutlinedPlusCircle, 'success'), self::adjustAction('debit', 'برداشت', Heroicon::OutlinedMinusCircle, 'danger'), ]); } private static function adjustAction(string $type, string $label, Heroicon $icon, string $color): Action { return Action::make($type) ->label($label) ->icon($icon) ->color($color) ->schema([ TextInput::make('amount') ->label('مبلغ (تومان)') ->numeric() ->required() ->minValue(1) ->integer(), Textarea::make('description') ->label('توضیحات') ->maxLength(500) ->rows(2), ]) ->action(function (Wallet $record, array $data, WalletService $walletService): void { try { $transaction = $type === 'credit' ? $walletService->credit($record, (int) $data['amount'], $data['description'] ?? null, auth()->user()) : $walletService->debit($record, (int) $data['amount'], $data['description'] ?? null, auth()->user()); Notification::make() ->title($type === 'credit' ? 'واریز انجام شد' : 'برداشت انجام شد') ->body('موجودی جدید: '.number_format($transaction->balance_after).' تومان') ->success() ->send(); } catch (RuntimeException $exception) { Notification::make() ->title('خطا') ->body($exception->getMessage()) ->danger() ->send(); } }); } }