using Request::is() function with named Routes Lar

2019-08-13 23:28发布

I was doing Request::is('/') which gave me true for example.com Now I am using named routes and for the name welcome

Route::get('/', function () {
    return view('admin_panel.welcome');
})->name('welcome');

Request::is(route('welcome')) returns false

What should I do. Note: I am using this for active states in navigation

2条回答
【Aperson】
2楼-- · 2019-08-14 00:17

You can use the routeIs method:

Request::routeIs('welcome');
查看更多
The star\"
3楼-- · 2019-08-14 00:22

I achieved this using Request::url() == route('welcome')which gave me truefor example.com

查看更多
登录 后发表回答