Merge branch 'develop' into fmcs-scope-check-updates-for-multiple-companies
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Labels;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
|
||||
class FieldOption
|
||||
{
|
||||
@@ -27,22 +28,19 @@ 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;
|
||||
}
|
||||
|
||||
return $asset->assignedTo ? $asset->assignedTo->full_name : null;
|
||||
}
|
||||
if ($dataPath[0] === 'displayName') {
|
||||
if ($asset->relationLoaded('assignedTo')) {
|
||||
|
||||
return $asset->assigned ? $asset->assigned->display_name : null;
|
||||
if ($dataPath[0] === 'displayName') {
|
||||
return $assigned->getRawOriginal('display_name') ?? $assigned->display_name;
|
||||
}
|
||||
|
||||
return $asset->assignedTo ? $asset->assignedTo->display_name : null;
|
||||
if ($assigned instanceof User) {
|
||||
return $assigned->full_name;
|
||||
}
|
||||
return $assigned->name ?? $assigned->display_name ?? null;
|
||||
}
|
||||
|
||||
// Handle Laravel's stupid Carbon datetime casting
|
||||
|
||||
Reference in New Issue
Block a user