Livewire Table export action export 1 row

Something is wrong please help me find out what. table is being populated with 10 rows but export csv/xlsx is 1 and data is wrong. Thanks in advance!
1 Reply
moodloid
moodloidOP2d ago
->headerActions([ ExportAction::make('export') ->label('Export') ->icon('heroicon-c-arrow-down-circle') ->exporter(DashboardCommodityExporter::class), ]) <?php namespace App\Filament\Exports; use App\Models\DashboardShowCommodity; use App\Models\DashboardShowTrade; use Filament\Actions\Exports\ExportColumn; use Filament\Actions\Exports\Exporter; use Filament\Actions\Exports\Models\Export; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\DB; class DashboardCommodityExporter extends Exporter { protected static ?string $model = DashboardShowCommodity::class; public static function getColumns(): array { return [ // columns ]; } public static function getCompletedNotificationBody(Export $export): string { $model = new (static::$model)(); activity('Access') ->event('Exported') ->performedOn($model) ->log('Export successful'); $body = 'Your dashboard commodity export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; if ($failedRowsCount = $export->getFailedRowsCount()) { $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; } return $body; } } Created custom view without accessing any function from model and it works fine.

Did you find this page helpful?