下载 pdf 格式的发票时遇到 404 错误
While Downloading Invoice in pdf facing 404 error
我正在使用 laravel cashier 10 和 stripe 7。我正在尝试下载发票 pdf 但遇到错误
enter image description here
pdf下载代码
return $request->user()->downloadInvoice($invoiceId, [
'vendor' => 'Focous Chain',
'product' => Plan::GetPlanById(Auth::user()->subscription('default')->stripe_plan)['interval'],
]);
路线是
Route::get('download/invoices/{invoice}', 'AccountController@downloadInvoice')->name('download.invoice');
在视图中
<a href="{{route('download.invoice', ['id',$invoice->id])}}" class="btn btn-primary">download</a>
您在视图中为下载路径传递了错误参数的值。
您必须传递为:
<a href="{{ route('download.invoice', ['invoice', $invoice->id]) }}" class="btn btn-primary">download</a>
目前您正在以错误的方式生成路线:
<a href="{{route('download.invoice', ['id',$invoice->id])}}" class="btn btn-primary">download</a>
将生成:
focuschain.com/download/invoices/id?in_1HDOhdEft5GkDC4vVsV36cpy
这里你传递id
作为路由参数{invoice}
这显然是不正确的,应该是in_1HDOhdEft5GkDC4vVsV36cpy
focuschain.com/download/invoices/in_1HDOhdEft5GkDC4vVsV36cpy
为了实现这一点,您可以执行以下操作:
<a href="{{ route('download.invoice', $invoice->id) }}" class="btn btn-primary">download</a>
我正在使用 laravel cashier 10 和 stripe 7。我正在尝试下载发票 pdf 但遇到错误 enter image description here
pdf下载代码
return $request->user()->downloadInvoice($invoiceId, [
'vendor' => 'Focous Chain',
'product' => Plan::GetPlanById(Auth::user()->subscription('default')->stripe_plan)['interval'],
]);
路线是
Route::get('download/invoices/{invoice}', 'AccountController@downloadInvoice')->name('download.invoice');
在视图中
<a href="{{route('download.invoice', ['id',$invoice->id])}}" class="btn btn-primary">download</a>
您在视图中为下载路径传递了错误参数的值。
您必须传递为:
<a href="{{ route('download.invoice', ['invoice', $invoice->id]) }}" class="btn btn-primary">download</a>
目前您正在以错误的方式生成路线:
<a href="{{route('download.invoice', ['id',$invoice->id])}}" class="btn btn-primary">download</a>
将生成:
focuschain.com/download/invoices/id?in_1HDOhdEft5GkDC4vVsV36cpy
这里你传递id
作为路由参数{invoice}
这显然是不正确的,应该是in_1HDOhdEft5GkDC4vVsV36cpy
focuschain.com/download/invoices/in_1HDOhdEft5GkDC4vVsV36cpy
为了实现这一点,您可以执行以下操作:
<a href="{{ route('download.invoice', $invoice->id) }}" class="btn btn-primary">download</a>