确定请求路径是否匹配模式
if (Request::is('admin/*'))
// What are the support patterns in laravel 4 request beside the wildcard?
{
//
}
我似乎无法找到提供更多示例而不仅仅是通配符的文档。
伙计们,我其实想要切换活动菜单css
在这种情况下:
{{ (Request::is('home')) ? 'active' : '' }}
要么
{{ (Request::segment(1) == 'home') ? 'active' : '' }}
要么
{{ (Request::path() == 'home/special') ? 'active' : '' }}
或自己做
{{ (preg_match('whatever you want here', Request::path()) ? 'active' : '') }}
编辑:查看Laravel核心中的Request :: is()函数:
/**
* Determine if the current request URI matches a pattern.
*
* @param string $pattern
* @return bool
*/
public function is($pattern)
{
foreach (func_get_args() as $pattern)
{
if (str_is($pattern, $this->path()))
{
return true;
}
}
return false;
}
所以你实际上可以传入任何'模式',它会匹配str_is()