Support the ongoing development of Laravel.io →
Eloquent

I have two models tag and post. When i create the tag I assign it like Post::find(1)->tags()->sync([1]). On each sync I want to increment/decrement tags countert. So basically I need just to call own method when sync is called. Is it possible?

Last updated 3 years ago.
0

Listen for the event. Laravel support many events out of the box.

0

jacksoncharles said:

Listen for the event. Laravel support many events out of the box.

Could you provide an example?

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.