mikebronner / laravel-pivot-events

MIT License
116 stars 8 forks source link

wrong parameters #8

Closed vardtheo closed 1 year ago

vardtheo commented 2 years ago

Great package, thank you for your work.

https://github.com/GeneaLabs/laravel-pivot-events/blob/3e076a8d266baf0833e7496ca4e5eb65d5df4b76/src/Traits/ExtendFireModelEventTrait.php#L39-L45

Setting the model two times one on key '0' and again on key 'model' passes that model two times in the Clojure which makes the parameter names invalid.

static::pivotSynced(function ($model, $relationName, $changes) {
    // $model is indeed model, key '0'
    // $relationName is **again** model, key 'model'
    // $changes is relation name, key 'relation'
    // etc
});

This occurs on other event methods as well, pivotAttaching, pivotDetached, etc.

Please fix that.