2016-12-16 27 views
0

在刀片,如果我们想检查当前路由与路由匹配与否,我们可以简单地使用:检查通配符路线5

@if(Route::currentRouteName() == 'parameter') 
{{ 'yes' }} 
@else 
{{ 'no' }} 
@endif 

但是,如果我们想用一个与之相匹配的是什么通配符如:

@if(Route::currentRouteName() == 'parameter.*') 
{{ 'yes' }} 
@else 
{{ 'no' }} 
@endif 

有没有解决方案?

我尝试过“*”和“:any”,但它没有奏效。

注意:我想检查路由,而不是URL。

任何帮助,将不胜感激。

感谢,

PARTH沃拉

回答

1

使用Laravel的string helper功能

str_is('parameter*', Route::currentRouteName()) 

它会为与parameter

+0

由于开始的字符串返回true,好像没有其他除了字符串比较外, –