mpociot / teamwork

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

Possible issue in UserHasTeams Trait? #8

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi there,

I'm toying around with your package and came across an issue, if one uses the package together with eg. the Entrust role based permission package.

If you add the EntrustUserTrait and the UserHasTeams Trait to your User Model, you'll cause an fatal error with the following message:

"Trait method boot has not been applied, because there are collisions with other trait methods on App\User"

Because both Traits have a boot method to reset the many to many relation on deletion. I'm not sure, if one can omit this by renaming the boot method to:

bootUserHasTeams

which should be called automatically by Laravel and don't call the parent boot method in that one. Also I'm not sure, if this keeps the desired behavior and works as expected?
And yes I could have asked the same question in the Entrust repo, but I thought this one is better maintained :)

mpociot commented 9 years ago

Hi,

thanks for reporting this issue! I fixed it by using bootUserHasTeams as you suggested. :+1:

ghost commented 9 years ago

Hi,

great! Glad to help :+1: So, it still works as expected? Came to another possible issue in the same method. I think in L5.* the Trait for the SoftDelete feature is called SoftDeletes and not SoftDeletingTrait like in L4.2, so the method body has to change to:

if ( !method_exists( \Config::get( 'auth.model' ), 'bootSoftDeletes' ) )

Or am I going in the wrong direction?

mpociot commented 9 years ago

Yes, you're right. Fixed it :)