You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Eloquent model is soft deleted on audits listing, attribute accessors and modifiers are not applied. $this->auditable is null in Audit trait.
Yup, this is expected. Like you mentioned, when fetching the related Auditable model, add the withTrashed() scope so that you don't get errors with accessors/modifiers.
Not everyone uses the SoftDeletes trait, so that's why it's not there in the first place.
Meanwhile, I did a PR which moves the relationship code from the Audit trait to the model. This should make it easier to just implement your own Audit model and set the Auditable and User relationships as you see fit.
Actual Behaviour
When Eloquent model is soft deleted on audits listing, attribute accessors and modifiers are not applied. $this->auditable is null in Audit trait.
Expected Behaviour
To be applied attributes accessors and modifiers.
Steps to Reproduce
Eloquent model attribute accessor:
public function getPrivateDataAttribute($value) { return Crypt::decrypt($value); }
or using Audit attribute modifier
protected $attributeModifiers = [ 'private_data' => CryptingEncoder::class, ];
`class CryptingEncoder implements AttributeEncoder
{
}`
Possible Solutions
Change relationship in Audit trait (Audit.php)
public function auditable(): MorphTo { return $this->morphTo()->withTrashed(); }
The text was updated successfully, but these errors were encountered: