Apr 1, 2020
0
Level 1
Laravel Nova Resource Tool Route
I have a resource detail button vue which uses a route to access a controller to download a pdf. This works fine if I use an anchor href e.g
<a :href="'/nova-vendor/custom-resource-toolbar/product/download/' +
this.$parent.resourceId"
class="btn btn-default btn-icon btn-white bg-primary"
style="background-color: var(--primary); color: white; margin-top: -2px; margin-left: 3px"
>
Sales as PDF
</a>
But I want some sort sort of feedback so I thought I would use a button click with a Nova.request().get.
<button class="btn btn-default btn-icon btn-white bg-primary" @click="activatePDF">TEST</button>
The method:
methods: {
activatePDF() {
Nova.request()
.get(
'/nova-vendor/custom-resource-toolbar/product/download/' +
this.$parent.resourceId
)
.then(this.$toasted.show('Success!', { type: 'success' }))
.catch(this.$toasted.show(error.response, { type: 'error' }));
console.log(response.data);
}
The route:
Route::get('/product/download/{id}', 'App\Http\Controllers\ProductController@downloadPDF');
All get is the "Success!" message but no download. I am a newbie but have tried many things including changing the get to a post adding .active to @click and much more but cannot get the pdf to download.
Please or to participate in this conversation.