Skip to content

Audit Formatting Doesn't Include Attribute Accessors #828

@hamedghaderi

Description

@hamedghaderi
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions