在我index.blade.php的代码如下:
href="/finance/reports?type=monthly&year={{ $month['year'] }}&month={{ $month['id'] }}"
Run Code Online (Sandbox Code Playgroud)
并在web.php文件路由中定义为:
Route::get('/reports', 'ReportsController@index')->name('reports');
Run Code Online (Sandbox Code Playgroud)
如何在 index.blade.php 中传递参数以使其成为命名路由。
它已经是一条命名路线。要从路由助手获取附加查询参数的命名路由的 URL:
route('reports', [
'type' => 'monthly',
'year' => $month['year'],
'month' => $month['id'],
]);
Run Code Online (Sandbox Code Playgroud)
将是:
http://yoursite/finance/reports?type=monthly&year=WhatEverThatIs&month=WhatEverThatWas
Run Code Online (Sandbox Code Playgroud)
我正在对您的路线进行假设,并且您在示例中使用的 URI 是准确的。
| 归档时间: |
|
| 查看次数: |
4976 次 |
| 最近记录: |