Skip to content
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

Merged
merged 3 commits into from
May 15, 2017
Merged

[5.4] Adds isRouteName method #19202

merged 3 commits into from
May 15, 2017

Conversation

mlantz
Copy link
Contributor

@mlantz mlantz commented May 15, 2017

Adds a isRouteName method to the Request.

For use cases such as Request::isRouteName(‘foo.bar’) this allows easier route changes in the future.

@mlantz mlantz changed the title Adds isRouteName method [5.4] Adds isRouteName method May 15, 2017
return true;
}

return false;
Copy link
Contributor

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;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

Copy link
Contributor

@decadence decadence May 15, 2017

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.

Copy link
Contributor

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.

@taylorotwell taylorotwell merged commit 2a42036 into laravel:5.4 May 15, 2017
@decadence decadence mentioned this pull request May 16, 2017
@ruchernchong
Copy link

ruchernchong commented May 30, 2017

Can this be used as request()->isRouteName()?

@decadence
Copy link
Contributor

decadence commented May 30, 2017

Yes, but original method was renamed to routeIs AFAIK

@mlantz
Copy link
Contributor Author

mlantz commented May 30, 2017

I tried isRouteName but it looks like it got switched :) still super handy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants