spatie / activitylog

A very simple activity logger to monitor the users of your website or application
https://spatie.be/opensource/laravel
MIT License
582 stars 75 forks source link

bootLogsActivity method never called #16

Closed florentsorel closed 8 years ago

florentsorel commented 8 years ago

Hi,

I use Log model events, so I've implemented the interface in my User model and add the trait, but the bootLogsActivity method is never called. So I've tried the code below in my model:

protected static function boot()
{
    self::bootLogsActivity();
}

public function getActivityDescriptionForEvent($eventName)
{
    dd($eventName);
    if($eventName == 'updated')
    {
        return trans('activity.user.updated', ['name' => $this->profile->present()->fullName]);
    }

    return '';
}

The die and dump is never called. What's wrong in my case ?

florentsorel commented 8 years ago

In Model class I saw boot method start the bootXXX method :)

The problem is, the updated event is never called in my case :/. created and deleted works but updated don't.

freekmurze commented 8 years ago

What are you doing to trigger an update? Are you changing a field on your model?

florentsorel commented 8 years ago

I use update method, User::update

freekmurze commented 8 years ago

And are you updating any values on the model? Laravel is smart enough not to send the update event when no values have changed.

freekmurze commented 8 years ago

I'm assuming that you never updated a value on your model, and that's why update wasn't called. If I'm wrong, reopen this issue.