ajr*_*eal 1 php laravel laravel-4
根据文档:
确定请求路径是否匹配模式
if (Request::is('admin/*'))
// What are the support patterns in laravel 4 request beside the wildcard?
{
//
}
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到提供更多示例而不仅仅是通配符的文档.
伙计们,我其实想要切换活动菜单css
在这种情况下:
{{ (Request::is('home')) ? 'active' : '' }}
Run Code Online (Sandbox Code Playgroud)
要么
{{ (Request::segment(1) == 'home') ? 'active' : '' }}
Run Code Online (Sandbox Code Playgroud)
要么
{{ (Request::path() == 'home/special') ? 'active' : '' }}
Run Code Online (Sandbox Code Playgroud)
或自己做
{{ (preg_match('whatever you want here', Request::path()) ? 'active' : '') }}
Run Code Online (Sandbox Code Playgroud)
编辑:查看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;
}
Run Code Online (Sandbox Code Playgroud)
所以你实际上可以传入任何'模式',它会匹配str_is()