Closed JesusLeon closed 8 years ago
Hey,
sorry for the late reply and thank you for taking the time to create this issue!
It would be great if you could create a PR for this - don't worry too much about the testing part, as we can work this out together :)
sir, Can you please give me an example project for your Teamwork package. I can't send invitation properly and also can't check invitation.please help me
Hi @mpociot,
I'm wondering if the test
UserHasTeamsTraitTest@testAttachTeamDoesNotAttachTeamIdWhenItExists
is actually testing the right thing: to prevent that a team is attached to a user more than once?The reason is that while playing with the package, when attaching a team to a user twice on the same routine it does not prevent a double attachment.
Example:
I guess you assumed that the team_ids are sanitized before using the attachTeam(s) method, but it would be good to have this as default on the package logics.
After playing a bit more, I noticed that eloquent many-to-many relation's attach() method does not reloads the relation after attaching, and therefore, using something like
$user->teams->contains( $team_id )
will return alwaysfalse
.By manually loading the relations before checking for existence, did the trick:
If this is correct, I would create a PR but unfortunately I'm not so familiar with the testing part. I will review it though and as soon I'm confident about it, I will send the PR (if I happen to have it ready faster than you :).
Thanks, J