问题
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 true
for example.com
来源:https://stackoverflow.com/questions/50655365/using-requestis-function-with-named-routes-laravel