mpociot / teamwork

User to Team associations with invitation system for the Laravel 5 Framework
MIT License
1.07k stars 170 forks source link

Switch currentTeam relationship from hasOne to belongsTo #143

Closed jeanlucnguyen closed 2 years ago

jeanlucnguyen commented 2 years ago

I believe there's a mistake on the type of relationship currentTeam should be.

As a current_team_id is added to the users table, the relationship between a user and a team should be belongsTo.

I discovered the mistake by trying to use a UserFactory with the ->for() method.

This would return a mistake $relationship->getOwnerKeyName() doesn't exist if you try to do User::factory()->for($team, 'currentTeam')->create()