Table Column for json value

I'm trying to create a view to display the audits table from the https://laravel-auditing.com project. The problem is that the old_values and new_values columns store data in json format of the type: {"usr_modificacion":1,"observaciones":"x"} and when it is displayed in the view, only the value of the field is displayed and not the name. In the example above it shows: 1, x. Can you give me some idea of how to display something like: usr_modificacion:1, observaciones: x? I am working with version 2 of filament. Thanks
Laravel Auditing
Laravel Auditing
Laravel Auditing allows you to record changes to an Eloquent model's set of data by simply adding its trait to your model.
3 Replies
Patrick Boivin
Patrick Boivinβ€’16mo ago
Maybe something like this, if you have an array cast on your model:
->formatStateUsing(function ($state) {
return collect($state)
->map(fn ($value, $key) => "$key: $value")
->join(', ');
})
->formatStateUsing(function ($state) {
return collect($state)
->map(fn ($value, $key) => "$key: $value")
->join(', ');
})
Martin
Martinβ€’15mo ago
GitHub
GitHub - TappNetwork/filament-auditing: A Filament plugin for Larav...
A Filament plugin for Laravel Auditing package. . Contribute to TappNetwork/filament-auditing development by creating an account on GitHub.
Hasith
Hasithβ€’15mo ago
Using $casts inside the model gets job done πŸ‘Œ
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'domains' => 'array',
];
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'domains' => 'array',
];
Want results from more Discord servers?
Add your server