Filament Export Action

Hi, I have this code for exporting it still work in Laravel 10 and Filament v3.2, but now I tried the same code in Laravel 11 Filament v3.2, it doesn't work. I see the problem doesn't create a filament_exports folder in public/storage.

ExportAction::make()
                ->label('تصدير')
                ->color('red')
                ->icon('heroicon-o-arrow-down-tray')
                ->exporter(ContactExporter::class)
                ->formats([
                    ExportFormat::Xlsx,
                ])
                ->fileName(fn (Export $export): string => "تصدير المساهمين-{$export->getKey()}")
                ->after(function () {
                $id = Export::latest()?->first()?->id;
                $path = 'filament_exports/' . $id . '/تصدير المساهمين-' . $id . '.xlsx';  // you can change the filename based on the Exporter

                if (Storage::disk('public')->exists($path)) {
                return response()->stream(
                    function () use ($path, $id) {
                        $stream = Storage::disk('public')->readStream($path);
                        dd($stream);
                        fpassthru($stream);
                        fclose($stream);

                        Storage::disk('public')->deleteDirectory('filament_exports/' . $id);
                        Export::truncate();
                    },
                    200,
                    [
                        'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                        'Content-Disposition' => 'attachment; filename=' . $id . '.xlsx',
                    ]
                );
                } else {
                    abort(404, 'الملف غير موجود.');
                }
            })


Any solution please?
Was this page helpful?