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

Audit Formatting Doesn't Include Attribute Accessors #828

Open
hamedghaderi opened this issue May 16, 2023 · 0 comments
Open

Audit Formatting Doesn't Include Attribute Accessors #828

hamedghaderi opened this issue May 16, 2023 · 0 comments

Comments

@hamedghaderi
Copy link
Contributor

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 10.8.0
Package version 13.5.0
PHP version 8.2

Actual Behaviour

Currently, when the Audit functionality formats data, it fails to detect and include attribute accessors of type "Attribute" during the formatting process. As a result, attribute accessors are not considered when formatting the data.

Expected Behaviour

It is expected that the Audit functionality should include attribute accessors of type "Attribute" during the data formatting process. This would ensure that any custom formatting defined through attribute accessors is properly considered.

Steps to Reproduce

  1. Assume we have a model Foo with a JSON attribute, bar, casted as an ArrayObject:
class Foo extends Model implements Auditable 
{
  protected $casts = [
     'bar' => AsArrayObject::class,
  ];
}
  1. Before fetching the bar attribute, we add custom formatting using an attribute accessor:
public function bar(): Attribute
{
  return Attribute::make(
    get: fn ($value) => // Some custom formatting 
  )
}
  1. The Audit functionality currently ignores this custom formatting because it only checks for attribute accessors starting with get, such as getBarAttribute.
Screenshot 2023-05-16 at 11 33 46 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant