Then rather than a download action response, we sent a redirect action response to another controller we defined with the filename attached. What we ended up doing was saving the file. A typical Laravel download response isn’t something Nova knows how to handle, and the built-in download action response doesn’t have a way to handle streams or deleting a file when it finishes. Generally, they’re a simple array of JSON data. Actions have fixed responses they can deliver that the Nova dashboard will understand. Alternatively, you can create a file and then delete it when the download has finished.īut Nova is a bit different. You don’t actually have to create a file. With a normal Laravel request, you can make use of streamed downloads to accomplish this – stream contents directly to the response. It could be tossed when the action had completed. The file download seemed like the ticket, but I didn’t really need the file to stick around. This can be as simple as a toast notification, and as complicated as a file download. When you run an action from the Nova dashboard, it fires off a request to the server and gets a response that tells the dashboard if the action was successful and if subsequent steps should be taken. While there are a million ways of accomplishing this, it seemed appropriate to build it as a Nova action, allowing users to explicitly select the models they want to export at a given time. This particular project required running a dump of models in the database to a CSV. “Actions” are a nifty tool that comes with Nova for running tasks across one or more models. We used it on a recent client project and have been thrilled with the results. Laravel Nova is a pretty great tool for configuring CRUD dashboards quickly and simply.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |