【发布时间】:2020-08-30 04:49:00
【问题描述】:
下午好。
我希望在启动我的应用程序时,通向仪表板的索引路径接收默认值“月”,以便用户看到的第一件事是按月过滤的信息。已经在仪表板中,我有一个选择器,它将生成相应的过滤器,但我不知道这是否会影响已经使用默认值定义的路由。
在 web.php 我有:
Route::get('merchant-dashboard/{filterDashboardMerchant}', 'HomeController@index')->name('merchant-dashboard')->middleware(['auth.shopify']);
$filterDashboardMerchant 是我用来过滤要显示的信息的变量,它获取'today'、'month'和'year'之间的值。
在控制器中我收到它是这样的:
public function index($filterDashboardMerchant)
{
.............
}
仪表板视图中的过滤器是以下选择:
<select id="filter-records" class="custom-select-design1">
<option value="{{ route('merchant-dashboard', $filterDashboardMerchant = 'today') }}" {{$filterDashboardMerchant==='today' ? 'selected="selected"' : ''}}>Today</option>
<option value="{{ route('merchant-dashboard', $filterDashboardMerchant = 'month') }}" {{$filterDashboardMerchant==='month' ? 'selected="selected"' : ''}}>Month</option>
<option value="{{ route('merchant-dashboard', $filterDashboardMerchant = 'year') }}" {{$filterDashboardMerchant==='year' ? 'selected="selected"' : ''}}>Year</option>
</select>
也许这是语法问题,但我尝试了几个选项,但没有一个对我有用。我希望你能帮助我。
谢谢。
【问题讨论】:
-
我缺少评论,我需要的是开始路线是这样的:myweb.com/merchant-dashboard/month
-
您遇到的实际错误是什么?