Format assigned to field

This commit is contained in:
Marcus Moore 2023-09-28 11:35:20 -07:00
parent a47e36c1e5
commit 4675f02349

View file

@ -14,6 +14,14 @@ class FieldOption {
public function getValue(Asset $asset) {
$dataPath = collect(explode('.', $this->dataSource));
// assignedTo directly on the asset is a special case where
// we want to avoid returning the property directly
// and instead return the entity's presented name.
if ($dataPath[0] === 'assignedTo'){
return $asset->assignedTo->present()->fullName();
}
return $dataPath->reduce(function ($myValue, $path) {
try { return $myValue ? $myValue->{$path} : ${$myValue}; }
catch (\Exception $e) { return $myValue; }
@ -46,4 +54,4 @@ class FieldOption {
return $option;
}
}
}
}