harryg
harryg

Reputation: 24077

Using `boot()` on a model conflicts with RevisionableTrait

I'm using the Revisionable package in my laravel app to log edits to a model.

In addition I have also implemented an observer class to listen for specific model events (update, delete, create etc) and perform actions (such as clear caches etc). This observer is instantiated in the model using the boot() method as follows:

class Client {
    use \Venturecraft\Revisionable\RevisionableTrait;
    public static function boot()
    {
        parent::boot();
        Client::observe(new App\Observers\ClientObserver);
    }
}

What I find is that when I define a boot() method in my model the Revisionable Trait stops working and does not log changes - presumably because it too uses a boot method that is being overridden by the one in the model.

How would I fix this to allow listening for model events as well as utilizing the Revisionable package?

Upvotes: 3

Views: 810

Answers (1)

userPlus
userPlus

Reputation: 349

this link helped me

https://github.com/VentureCraft/revisionable/issues/175

I used in laravel 5.1 i hope it will work to you

use RevisionableTrait, UuidTrait {
        UuidTrait::boot insteadof RevisionableTrait;
    }

Upvotes: 0

Related Questions