Add bulk action to table to export selected record as JSON file within a ZIP archive
Tables\Actions\BulkAction::make('exportAllAsJson') ->label(__('Export All')) ->icon('heroicon-s-download') ->action(function (Collection $records) { $archive = new \ZipArchive; $archive->open('file.zip', \ZipArchive::CREATE | \ZipArchive::OVERWRITE); foreach ($records as $record) { $name = Str::slug($record->name, '_') . '.json'; $return = $record->attributesToArray(); $content = json_encode($return, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR); $archive->addFromString($name, $content); } $archive->close(); return response()->download('file.zip'); }) ->deselectRecordsAfterCompletion()
hi, it does not work
im using https://github.com/barryvdh/laravel-dompdf/tree/v2.0.0
I'm running in to the same issue. Same package. The download() functions returns a Response object, but the download is not starting.
Tengo mismo el mismo problema. han aencontrado alguna solución?