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

[8.x] add common 4xx error status code boolean methods to response class #39979

Merged
merged 2 commits into from
Dec 11, 2021
Merged

[8.x] add common 4xx error status code boolean methods to response class #39979

merged 2 commits into from
Dec 11, 2021

Conversation

hendeavors
Copy link
Contributor

This adds methods to check 401 and 403 status codes, respectively. I think these are pretty common status codes to work with when consuming an api.

Before:

if ($response->status() === 401) {
    // ...
}

if ($response->status() === 403) {
    // ...
}

After:

if ($response->unauthorized()) {
    // ...
}

if ($response->forbidden()) {
    // ...
}

@taylorotwell taylorotwell merged commit 5eee71c into laravel:8.x Dec 11, 2021
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.

2 participants