Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observer for Pivot Model not firing #467

Open
Restingo opened this issue May 19, 2024 · 3 comments
Open

Observer for Pivot Model not firing #467

Restingo opened this issue May 19, 2024 · 3 comments
Assignees

Comments

@Restingo
Copy link

Describe the bug
I've got two models, lets name them Company and Contact. I've also got a pivot model CompanyContact. For the pivot model I've created an observer that is called CompanyContactObserver.

Now if model caching is enabled via .env file the CompanyContactObserver doesn't fire.

Eloquent Query
Please provide the complete eloquent query that caused the bug, for example:

$company->contacts()->sync($contacts);

Stack Trace
None.

Environment

  • PHP: 8.1.28
  • OS: Ubuntu 22.04.4 LTS
  • Laravel: 10.44.0
  • Model Caching: 0.13.9

Additional context
If model caching is disabled the observer fires instantly.

@mikebronner
Copy link
Owner

@Restingo thank you for reporting this. If you can provide a PR with a failing test, or even the fix, that would help out tremendously.

@Restingo
Copy link
Author

@mikebronner thanks for your fast response. Would it also be sufficient to commit the models and some test controller? I don't know in which file I need to put the test case :(

@mikebronner
Copy link
Owner

@Restingo Hey, in that case I would recommend just setting up a test repo that demonstrates the problem (comment the code where the problem happens). That will help write the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants