-
Notifications
You must be signed in to change notification settings - Fork 390
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
Omit casting on a per attribute basis - open to a PR? #635
Comments
This is over a year old but no comments, I definitely think this would benefit the package. |
Not only do I have the same requirements, but also the current version has a bug on this. After transforming the data, it doest get stored correctly. However, when retrieving getModified(), it doesn't return the data from the audit table, it fetch the current information from the database. Meaning the status we transformed before won't be even showing when you use getModified to show the audit data. |
Had completely forgotten about this. Since I raised this I've unfortunately been using the |
We are working on a solution, but have to be careful with regards to backwards compatibility. Related to this: #799 |
Right. To get back to this, i am sorry to say i don't understand what the desired outcome is. If possible, please outline what the desired behaviour is, or describe how to reproduce the problem. |
Hi,
Would the package maintainer be open to a PR for the following?
Allow an array of attributes that shouldn't be cast, to be specified on a per model basis?
From http://www.laravel-auditing.com/docs/9.0/audit-transformation I can see here a new key
role_name
has been specified, but it seems odd to introduce keys outside the scope of your model.Example, assume I have a
task
model with astatus_id
column.status_id
is cast to an integer.On the task model the
transformAudit()
method has been specified as follows:Note here, as the documentation suggests I could simply specify a different key, other than
status_id
. However, doing so causes both keys to be present in the database old and new columns. To only store the new key I have to omit the old key i.e.Instead of storing the old an new
status_id
integers, the status title is being stored as a string.Within the audits table:
As this package now honours Eloquent casts, within my auditable view, the old an new
status_id
values are always zero - as expected due to the model casts.I could remove the casts within the tasks model. However, this is an existing project that makes use of strict comparisons.
I'd propose a very simple PR to accommodate this.
Within the package
Audit
model, adjust thegetDataValue
method to account for an excluded attribute. If excluded, simply the return the raw value:Would this be something the package owner would consider?
Thanks
The text was updated successfully, but these errors were encountered: