Describe the bug
As far as i know, attributesToBeLogged always contains mutated data, but when ActivityLog suppose to ignore casts, using useAttributeRawValues(), mutation method will ignore
To Reproduce
it('can ignore cast and store mutated value while attribute has mutator', function () {
$articleClass = new class() extends Article {
use LogsActivity;
protected $casts = [
'status' => 'string',
];
public function getStatusAttribute($value)
{
return $value ? 'Show' : 'Hide';
}
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logOnly(['status'])->useAttributeRawValues(['status']);
}
};
$article = new $articleClass();
$article->status = 1;
$article->save();
$this->assertEquals($article->status, $this->getLastActivity()->properties['attributes']['status']); // expected 'Show' but '1' given
});
If you use useAttributeRawValues(['status'])
"attributes" => [
"status" => 1
]
If you use useAttributeRawValues([])
"attributes" => [
"status" => "Show"
]
Versions
PHP: 8.0
Database: mysql
I'm not sure if its correct behavior or not, but based on documentation useAttributeRawValues let ActivityLog to store the data without casting and it's just not about mutation.
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
Describe the bug As far as i know, attributesToBeLogged always contains mutated data, but when ActivityLog suppose to ignore casts, using useAttributeRawValues(), mutation method will ignore
To Reproduce
If you use useAttributeRawValues(['status'])
If you use useAttributeRawValues([])
Versions
I'm not sure if its correct behavior or not, but based on documentation useAttributeRawValues let ActivityLog to store the data without casting and it's just not about mutation.