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

大城市里の小女人 提交于 2019-12-24 17:15:34

问题


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


回答1:


You can use the routeIs method:

Request::routeIs('welcome');



回答2:


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



来源:https://stackoverflow.com/questions/50655365/using-requestis-function-with-named-routes-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!