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

Use data_get() for placeholder replacement instead of Arr::get() #1038

Merged
merged 4 commits into from
Apr 21, 2022

Conversation

stevebauman
Copy link
Contributor

Description

This PR replaces the usage of Arr::get() with data_get() for retrieving placeholder values, so model properties (and deeply nested properties) can be logged.

Problem

In the documentation it states:

These placeholders will get replaced with the properties of the given subject, causer or property.

However, this is not the case, as model properties cannot be reached with placeholders -- only model attributes.

Also, calling $model->toArray() inadvertently executes and caches model accessors via the $appends property, which can cause unneeded overhead if a developer has configured queries to be executed in these accessors.

This PR resolves the above issues by using Laravel's data_get() helper, which reaches into objects (and deeply nested objects) via dot-notated key.

@Gummibeer
Copy link
Collaborator

Thanks for the fix! 🎉

@Gummibeer Gummibeer merged commit d774c23 into spatie:main Apr 21, 2022
@Gummibeer
Copy link
Collaborator

@stevebauman
Copy link
Contributor Author

Happy to help @Gummibeer!

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

Successfully merging this pull request may close these issues.

None yet

2 participants