How to stream download data from current view in Laravel 5.7
up vote
0
down vote
favorite
I am making a basic database application that allows users to submit search parameters through a form and have the results displayed in a view. I create a query from an Eloquent model, paginate, and then send the results to a view.
I would like to place a link on the results view that lets users download the results of their query in a csv file, but stream the data rather than create a file and then serve it. My problem is that I don't know how to pass the query from the results page through a route to another controller that handles the download.
The information I have found about sending data to a route involves sending parameters for a url which I am not sure helps me.
I was thinking I could cache the results by sending the data from the controller handling the query to the controller handling the download before sending it to a view, but I am not sure how to accomplish this or if Laravel provides a better way to do what I want.
php laravel-5.7
add a comment |
up vote
0
down vote
favorite
I am making a basic database application that allows users to submit search parameters through a form and have the results displayed in a view. I create a query from an Eloquent model, paginate, and then send the results to a view.
I would like to place a link on the results view that lets users download the results of their query in a csv file, but stream the data rather than create a file and then serve it. My problem is that I don't know how to pass the query from the results page through a route to another controller that handles the download.
The information I have found about sending data to a route involves sending parameters for a url which I am not sure helps me.
I was thinking I could cache the results by sending the data from the controller handling the query to the controller handling the download before sending it to a view, but I am not sure how to accomplish this or if Laravel provides a better way to do what I want.
php laravel-5.7
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there isresponse()->streamDownload()
if you're generating it yourself on the fly.
– Travis Britz
Nov 8 at 2:51
I am not using any libraries. I know aboutresponse()->streamDownload()
but I don't know how I can do that from within a view.
– Registered User
Nov 11 at 0:54
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am making a basic database application that allows users to submit search parameters through a form and have the results displayed in a view. I create a query from an Eloquent model, paginate, and then send the results to a view.
I would like to place a link on the results view that lets users download the results of their query in a csv file, but stream the data rather than create a file and then serve it. My problem is that I don't know how to pass the query from the results page through a route to another controller that handles the download.
The information I have found about sending data to a route involves sending parameters for a url which I am not sure helps me.
I was thinking I could cache the results by sending the data from the controller handling the query to the controller handling the download before sending it to a view, but I am not sure how to accomplish this or if Laravel provides a better way to do what I want.
php laravel-5.7
I am making a basic database application that allows users to submit search parameters through a form and have the results displayed in a view. I create a query from an Eloquent model, paginate, and then send the results to a view.
I would like to place a link on the results view that lets users download the results of their query in a csv file, but stream the data rather than create a file and then serve it. My problem is that I don't know how to pass the query from the results page through a route to another controller that handles the download.
The information I have found about sending data to a route involves sending parameters for a url which I am not sure helps me.
I was thinking I could cache the results by sending the data from the controller handling the query to the controller handling the download before sending it to a view, but I am not sure how to accomplish this or if Laravel provides a better way to do what I want.
php laravel-5.7
php laravel-5.7
asked Nov 7 at 19:10
Registered User
234
234
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there isresponse()->streamDownload()
if you're generating it yourself on the fly.
– Travis Britz
Nov 8 at 2:51
I am not using any libraries. I know aboutresponse()->streamDownload()
but I don't know how I can do that from within a view.
– Registered User
Nov 11 at 0:54
add a comment |
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there isresponse()->streamDownload()
if you're generating it yourself on the fly.
– Travis Britz
Nov 8 at 2:51
I am not using any libraries. I know aboutresponse()->streamDownload()
but I don't know how I can do that from within a view.
– Registered User
Nov 11 at 0:54
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there is
response()->streamDownload()
if you're generating it yourself on the fly.– Travis Britz
Nov 8 at 2:51
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there is
response()->streamDownload()
if you're generating it yourself on the fly.– Travis Britz
Nov 8 at 2:51
I am not using any libraries. I know about
response()->streamDownload()
but I don't know how I can do that from within a view.– Registered User
Nov 11 at 0:54
I am not using any libraries. I know about
response()->streamDownload()
but I don't know how I can do that from within a view.– Registered User
Nov 11 at 0:54
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53196215%2fhow-to-stream-download-data-from-current-view-in-laravel-5-7%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you using a specific excel library, like maatwebsite/excel? They often have a method for downloading csv files from memory. Otherwise there is
response()->streamDownload()
if you're generating it yourself on the fly.– Travis Britz
Nov 8 at 2:51
I am not using any libraries. I know about
response()->streamDownload()
but I don't know how I can do that from within a view.– Registered User
Nov 11 at 0:54