首页 > 解决方案 > 如何在 Laravel 的命名路由中传递参数

问题描述

我想在我的刀片模板中传递url中的参数,url是:

href="/finance/invoices/download/{{ $invoice->file_path }}

在 web.php 中,路由定义为:

Route::get('invoices/download/{year}/{month}/{file}','InvoiceController@download')->name('download');

并且文件在数据库中存储为:

2018/07/invoiceberry_invoice_template_1.docx

我该怎么做?

标签: laravel

解决方案


要添加到先前的答案,请执行以下操作:

route('download',['year' => $year, 'month' => $month, 'file' => $file]);

推荐阅读