laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.98k stars 822 forks source link

allUsers may error if owner is null #1529

Closed dorkster100 closed 2 months ago

dorkster100 commented 3 months ago

Team->allUsers() may error out, if $this->owner is null. This may happen if user was deleted (team owner has no foreign index ), meaning user referenced in user_id column will not exist in users table, thus returning null. In this case $this->users->merge([null]) which errors.

On further work on my features I found more issues, for example when adding team members, the owner is expected in the stub AddTeamMember, I believe it should be possible to add team members to a team without owner (for example in my case I have Admin users).

taylorotwell commented 2 months ago

This should never be null.

dorkster100 commented 2 months ago

Can you please elaborate a bit? Should users be not deleteable or do you think if user is deleted, then the team should be deleted as well or team should automatically get new owner?

Actually nevermind, I see in the DeleteUser action that idea is to delete all owned teams.