Skip to content
This repository has been archived by the owner on Jun 1, 2019. It is now read-only.

Logging Old and New Values on Update #21

Closed
codydh opened this issue Oct 22, 2015 · 1 comment
Closed

Logging Old and New Values on Update #21

codydh opened this issue Oct 22, 2015 · 1 comment

Comments

@codydh
Copy link

codydh commented Oct 22, 2015

I'm trying to implement logging on a model of mine. Namely, when a value is updated, I'd like to log what the previous value was, and what the new value is. Is there a straightforward way to do this using ActivityLog?

@sebastiandedeyne
Copy link
Member

You'd have to manually bind an event to updating. Quick example:

protected static function boot()
{
    static::updating(function ($model) {
        Activity::log("{$model->name} just updated to {$model->getOriginal('name')}");
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants