使用带有命名路由Laravel的Request :: is()函数 [英] using Request::is() function with named Routes Laravel

查看:540
本文介绍了使用带有命名路由Laravel的Request :: is()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做Request::is('/'),这给了我true来表示example.com现在我使用的是命名路由和名字welcome

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'))返回false

我该怎么办.注意:我将其用于导航中的活动状态

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

推荐答案

您可以使用routeIs方法:

Request::routeIs('welcome');

这篇关于使用带有命名路由Laravel的Request :: is()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆