Commit b5b59176 authored by Mehedi Hassan's avatar Mehedi Hassan

Abstract csv download inside Response macro

parent dec0d481
......@@ -345,3 +345,11 @@ Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array
return new HtmlString($string);
});
Response::macro('csv', function ($file, $filename, $status = 200, $headers = []) {
return response($file, $status, array_merge([
'Content-Type' => 'application/csv',
'Content-Disposition' => "attachment; filename={$filename}",
'Pragma' => 'no-cache',
], $headers));
});
......@@ -53,11 +53,7 @@ class TranslationController extends AdminBaseController
public function export(TranslationsExporter $exporter)
{
return response()->make($exporter->export(), 200, [
'Content-Type' => 'application/csv',
'Content-Disposition' => "attachment; filename={$exporter->getFileName()}",
'Pragma' => 'no-cache',
]);
return response()->csv($exporter->export(), $exporter->getFileName());
}
public function import(ImportTranslationsRequest $request, TranslationsImporter $importer)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment