Label Fields: Fixes location assignedTos coming back null
This commit is contained in:
@@ -27,22 +27,17 @@ class FieldOption
|
||||
// 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') {
|
||||
if ($asset->relationLoaded('assignedTo')) {
|
||||
// If the "assignedTo" relationship was eager loaded then the way to get the
|
||||
// relationship changes from $asset->assignedTo to $asset->assigned.
|
||||
return $asset->assigned ? $asset->assigned->full_name : null;
|
||||
if (in_array($dataPath[0], ['assignedTo', 'displayName'])) {
|
||||
$assigned = $asset->relationLoaded('assignedTo') ? $asset->assigned : $asset->assignedTo;
|
||||
|
||||
if (!$assigned) {
|
||||
return null;
|
||||
}
|
||||
if ($dataPath[0] === 'displayName') {
|
||||
return $assigned->getRawOriginal('display_name') ?? $assigned->display_name;
|
||||
}
|
||||
|
||||
return $asset->assignedTo ? $asset->assignedTo->full_name : null;
|
||||
}
|
||||
if ($dataPath[0] === 'displayName') {
|
||||
if ($asset->relationLoaded('assignedTo')) {
|
||||
|
||||
return $asset->assigned ? $asset->assigned->display_name : null;
|
||||
}
|
||||
|
||||
return $asset->assignedTo ? $asset->assignedTo->display_name : null;
|
||||
return $assigned->display_name;
|
||||
}
|
||||
|
||||
// Handle Laravel's stupid Carbon datetime casting
|
||||
|
||||
Reference in New Issue
Block a user