Skip to content

Conversation

@rbondoc96
Copy link
Member

@rbondoc96 rbondoc96 commented Nov 22, 2024

Deleted Models: When records are soft deleted, the morphTo relationships return null. This allows records that have been soft deleted to still be returned.

  • This affects the logger:audit-resolver command. Now, the entity relationship can be loaded even if the Entity has been deleted.
  • While the owner relationship isn't loaded as part of the command, adding withTrashed to it will allow the owner to be loaded when dealing with the audit record directly.

LazyLoadingViolation Error: This error may occur when calling trackableOwnerResolver on an entity and the resulting owner model was already previously loaded (2+ entities are referring to the same owner in type and ID, see rows with IDs 3-8 below)

image

To fix this, every tracked model must define a getOwnerRelationshipName function that returns the name of the owner relationship to be loaded, or null if a tracked model/entity is also its owner. The return value of this function is used to load the owner relationships when the logger:audit-resolver command is ran.

@rbondoc96 rbondoc96 changed the title update: allow deleted owners and entities to be resolved Allow Deleted Owners and Entities to be Resolved and Fix LazyLoadingViolation When Loading Owners Nov 25, 2024
@rbondoc96 rbondoc96 marked this pull request as ready for review November 25, 2024 22:23
@rbondoc96 rbondoc96 merged commit 89fe4f8 into master Nov 26, 2024
6 checks passed
@rbondoc96 rbondoc96 deleted the track-deleted-records branch November 26, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants