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

HasTeams.php: make belongsToTeam accept null team #986

Merged
merged 2 commits into from
Feb 28, 2022
Merged

HasTeams.php: make belongsToTeam accept null team #986

merged 2 commits into from
Feb 28, 2022

Conversation

cholladay0816
Copy link
Contributor

This will allow users to pass a null value into belongsToTeam and have it return false instead of blowing up, similarly to ownsTeam.

It makes intuitive sense that if you were to Find() a team, for example, and it came back null, you could pass that in and simply get the response back that you do not belong to the team since it does not exist.

In my case, teams are able to have nullable parentTeam's, so for my policy I would like to be able to simply pass:
can view: $user->belongsToTeam($user->currentTeam->parentTeam)

It would allow me to write more elegant code than wrapping all of these in a check for if they're null or not.

This will allow users to pass a null value into belongsToTeam and have it return false instead of blowing up
@taylorotwell taylorotwell merged commit 2853615 into laravel:2.x Feb 28, 2022
@cholladay0816 cholladay0816 deleted the patch-1 branch February 28, 2022 17:24
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