-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.4] Adds isRouteName method #19202
Conversation
src/Illuminate/Http/Request.php
Outdated
return true; | ||
} | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be reduced to just return $this->route()->getName() === $name;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better: $this->route()->currentRouteNamed($name)
P.S. I'm wrong, this method only for Route facade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth to add method isName
for Route instances.
Can this be used as |
Yes, but original method was renamed to |
I tried isRouteName but it looks like it got switched :) still super handy :) |
Adds a
isRouteName
method to the Request.For use cases such as
Request::isRouteName(‘foo.bar’)
this allows easier route changes in the future.