Search code examples
laravel-4eloquentrevision

Get edited attributes in eloquent before update


I have tried Revisionable to make revisions of my Eloquent models, but it doesn't work with one of my models named Person

use Illuminate\Database\Eloquent\SoftDeletingTrait;

class Person extends Eloquent
{
    use SoftDeletingTrait;

    protected $dates = ['deleted_at'];

    protected $table = 'persons';
}

Many people has experienced this problem , but it isn't solved yet.

Now i want to make something on my own.

Is it possible to get the old attributes before saving the new in this method?

Person::updating(function($person)
{

});

I want to make a revision table which stores the old attributes for the person table.


Solution

  • Person::updating(function($person)
    {
        $original = $person->getOriginal();
    });