Skip to content

A free open source IT asset/license management system

Format assigned to field

Marcus Moore4675f02349bd
diff --git a/app/Models/Labels/FieldOption.php b/app/Models/Labels/FieldOption.php
index 76427accaf..2f874ec389 100644
--- a/app/Models/Labels/FieldOption.php
+++ b/app/Models/Labels/FieldOption.php
@@ -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;
}
}
-}
\ No newline at end of file
+}