如何在刀片模板中获取分组路线?
php中的分组路线如下:
routes.php文件
...
//player section
Route::group(['prefix' => 'test'], function() {
Route::get('{slug}/{id}', [
'uses' => 'TestController@getTest',
'as' => 'getTest',
]);
Route::get('{slug}/{id}/report', [
'middleware' => 'auth',
'uses' => 'TestController@reportTest',
'as' => 'reportTest',
]);
});
...
在刀片模板中,我按照<{1}}字符串
获取单个路由'as'
但是如何在刀片模板中获取前缀为@if(Route::is('playTest'))
<!-- some html here -->
@endif
的所有路由?
我想阻止用它的名字写下所有路线,如:
'test'
答案 0 :(得分:2)
你应该可以这样做:
@if(Request::route()->getPrefix() === 'test')
<!-- some html here -->
@endif
请参阅:https://laravel.com/api/master/Illuminate/Routing/Route.html#method_getPrefix