Merge pull request #14729 from snipe/fixes/attribute_for_purchase_date

Sets purchase date as date (versus datetime) in labels
This commit is contained in:
snipe 2024-05-16 18:49:49 +01:00 committed by GitHub
commit 84a601f364
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,11 @@ class FieldOption {
return $asset->assignedTo ? $asset->assignedTo->present()->fullName() : null;
}
// Handle Laravel's stupid Carbon datetime casting
if ($dataPath[0] === 'purchase_date') {
return $asset->purchase_date ? $asset->purchase_date->format('Y-m-d') : null;
}
return $dataPath->reduce(function ($myValue, $path) {
try { return $myValue ? $myValue->{$path} : ${$myValue}; }