Last active
March 2, 2021 21:41
-
-
Save paperscissors/f9d2a57eb949239f5b4db18657610894 to your computer and use it in GitHub Desktop.
LAravel response macro for file attachment download response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Response::macro('attachment', function ($content, $filename) { | |
$headers = [ | |
'Content-type' => 'text/plain', | |
'Content-Disposition' => 'attachment; filename="'.$filename.'"', | |
]; | |
return Response::make($content, 200, $headers); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment