Logging Actions with Laravel Morph Maps #3626
crynobone
announced in
Tips & Tricks
Replies: 1 comment 1 reply
-
Is this a workaround or by design? How is that used for polymorphic many to many (e.g. Tags from Laravel and Laravel Nova example)? For each of the models using Tags I currently have:
Laravel documentation states that:
Don't think the Tags example is a custom pivot model, but regardless: what would a complete pivot class example using |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel Nova will store all actions completed and will utilise
Relation::morphMap()
if defined. It's also true withRelation::enforceMorphMap()
however you have to be aware that you would need to define all Models and Pivot Models used to define Resource.As an example, imagine you have
Role
andUser
with belongs-to-many relationship andPost
,Tag
with morph-to-many relationship:As shown above, you need to also define the Pivot Model used to allow Laravel Nova to properly log attaching and detaching roles events in the application when you used
Relation::enforceMorphMap()
.Beta Was this translation helpful? Give feedback.
All reactions