Laravel-activitylog: Collisions with other trait method

Created on 9 Jan 2017  路  2Comments  路  Source: spatie/laravel-activitylog

Thank for this amazing package, i am having an issue

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

if a model uses both traits LogsActivity and CausesActivity it throws the error.

I can implement my own but is their a different solution?

Thanks

revisit for next major version

Most helpful comment

i figured out the way around this using php traits conflict handling.

if we have a user model and want to log activity on user model and we also want it to be the causer

use CausesActivity, LogsActivity {
        LogsActivity::activity insteadof CausesActivity;
        CausesActivity::activity as log;
    }

now we have 2 available methods, activity and log.

Thanks.

Not closing the issue because this doesn't work by default

All 2 comments

i figured out the way around this using php traits conflict handling.

if we have a user model and want to log activity on user model and we also want it to be the causer

use CausesActivity, LogsActivity {
        LogsActivity::activity insteadof CausesActivity;
        CausesActivity::activity as log;
    }

now we have 2 available methods, activity and log.

Thanks.

Not closing the issue because this doesn't work by default

Thanks for posting your solution. Closing this for now and will fix the collision in the next major version of the package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucianobosco picture lucianobosco  路  5Comments

jeangomes picture jeangomes  路  5Comments

hackel picture hackel  路  5Comments

kcristella picture kcristella  路  5Comments

chriship picture chriship  路  4Comments