Could you please allow to change file name (.pdf) in download invoice or can I custom the name of the download file, Now it's like fixed file name .
https://github.com/laravel/cashier/blob/9.0/src/Invoice.php#L269
many thanks.
@4UForever download method returns Response object, so you can just change a header:
use Illuminate\Http\Request;
Route::get('user/invoice/{invoice}', function (Request $request, $invoiceId) {
$response = $request->user()->downloadInvoice($invoiceId, [
'vendor' => 'Your Company',
'product' => 'Your Product',
]);
$filename = 'custom.pdf';
$response->headers->set('Content-Disposition', 'attachment; filename="'.$filename.'"');
return $response;
});
@Sti3bas many thanks for your advise and your sample code is so helpful for me. :)
I've sent in a PR for this here: https://github.com/laravel/cashier/pull/723
Most helpful comment
I've sent in a PR for this here: https://github.com/laravel/cashier/pull/723