Model’s column alias question (accessors/old_values/new_values) #965
-
I followed this tut: https://medium.com/@steno983/laravel-models-column-alias-c48a75065fb9 The main point is changing the column name in the database from Example: class Customer extends Model implements AuditableContract
{
use Auditable;
protected $table = 'customer';
// Accessors
protected function name(): Attribute
{
return Attribute::make(
get: fn(mixed $value, array $attributes) => $attributes['customer_name'],
set: fn(string $value) => [
'customer_name' => $value,
],
);
}
// Append
protected $appends = ['name'];
// Hide
protected $hidden = ['customer_name'];
} The
not as expected result that I want like this…:
Is there anything I'm missing, or is there a way I can improve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
laravel-auditing/config/audit.php Lines 71 to 75 in 9357577 laravel-auditing/src/Auditable.php Line 99 in 9357577 laravel-auditing/src/Auditable.php Lines 125 to 126 in 9357577 It is the expected behaivor |
Beta Was this translation helpful? Give feedback.
laravel-auditing/config/audit.php
Lines 71 to 75 in 9357577
laravel-auditing/src/Auditable.php
Line 99 in 9357577
laravel-auditing/src/Auditable.php
Lines 125 to 126 in 9357577
It is the expected behaivor