cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
559 stars 72 forks source link

Detag on delete #77

Closed pierrocknroll closed 6 years ago

pierrocknroll commented 6 years ago

Hello,

It could be great for the database consistency to detag on a deleted model (if it is not soft deleted).

I think you can do something like :

static::deleting(function ($model) {
    if (!method_exists($model, 'runSoftDelete') || $model->isForceDeleting()) {
        $model->detag();
    }
});

Thanks

cviebrock commented 6 years ago

The main idea being that it would help clean up the polymorphic table, right?

I'd be totally open to a PR that did this, if you have time. 😉

pierrocknroll commented 6 years ago

Yeah, ok I'll do it !