-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Pivot events do not fire #8452
Comments
has your user_role table an eloquent model? |
@tpavlek There are no pivot events at all. Your model is not used by the It would require changing the way this relation works, or adding such events to be fired. The latter was rejected by Taylor long time ago, can't remember why. |
Closing due to inactivity. |
@GrahamCampbell I don't really understand the justification for closing? Is this the same as labeling this a wontfix? |
@GrahamCampbell Is it possible to re-open/consider this? There are a number of other issues/PRs/feature-requests all relating to the same thing; Some have workaround in app-level code but it seems widely expected that the framework should fire events on pivot table changes. I think the limitation is that BelongsToMany doesn't use the Pivot model to interface with the DB but uses Query Builder directly; so doesn't benefit from the events Model provides. Should BelongsToMany be updated to use the Pivot model - or - should BelongsToMany just fire it's own events? Or some other mechanism? It'd be good to get some feedback as to what a good approach here would be before coming up with a PR. |
I just want to point out that without Pivot model events or a way to override http://stackoverflow.com/questions/37569142/overriding-attach-method-from-belongstomany-relationship This is a real problem when trying to implement concepts from graph databases, since instead of being able to say I am considering extending the I feel this level of obfuscation is hurting developer productivity for more advanced use cases. We already have
or something to that effect for setting these columns upon |
take a look at my package : https://github.com/fico7489/LaravelPivot |
This should be fired by framework itself. |
Why can't you use Model observers to handle real model events, also including relationship events in your flow as well? |
When creating (or performing any other action on a Pivot table), no model events are fired.
There is a proof of concept repository here: https://github.com/tpavlek/pivot-events-test
WelcomeController@index
creates a new user and a new role, and attaches the role to the user. inAppServiceProvider
we register this inboot()
Even after running the function in
WelcomeController
no data is logged, meaning no Pivot creating event was fired.The text was updated successfully, but these errors were encountered: