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

Added the missing 'trashed' event to getObservablesEvents() #55004

Open
wants to merge 1 commit into
base: 12.x
Choose a base branch
from

Conversation

duemti
Copy link

@duemti duemti commented Mar 13, 2025

Fixes #54980

I genuinely think this event was somehow forgot to be added there already.

Added the missing 'trashed' which gets registered with observers, so that observers too can listen to it besides listeners.
As per docs:

Eloquent models dispatch several events, allowing you to hook into the following moments in a model's lifecycle: retrieved, creating, created, updating, updated, saving, saved, deleting, deleted, trashed, forceDeleting, forceDeleted, restoring, restored, and replicating.

No breaking changes.

From the docs developers expect to listen to this event but if one uses observers then by default the observer would not be able catch it because it never was registered. This forced developers to redeclare the $observables in the model but this event belongs to the framework so it should not be missing by default from the already hard-coded event names array in getObservablesEvents().

No tests.

Fixes laravel#54980

Previous pull laravel#54987 but this one is more clear and inline.
@crynobone
Copy link
Member

No, only documentation for Observer should be updated to cover the different events available.

@duemti
Copy link
Author

duemti commented Mar 13, 2025

So you are saying that this event should not be available in observers by default?
Can i ask the reason?

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

Successfully merging this pull request may close these issues.

Observer does not listen to "trashed" event from Model
2 participants