Events on Pivot table

Hi there,

I've got two tables linked by a Many-to-Many relationship.


  • id


  • user_id
  • item_id


  • id

When querying for all the items a user has I'm caching the result. So now I'm trying to forget the Cache every time an item is attached / detached to the user.

I've found this little piece of code but unfortunately the event isn't fired (after placing it in the boot method of the User model):

Pivot::created(function ($pivot)) {

Any pointers as to how I can listen to attach / detach / sync?

Thanks in advance!

fico7489 replied 3 months ago

use this package

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us