diff --git a/src/NovaBelongsToDepend.php b/src/NovaBelongsToDepend.php index 0b413df..0514246 100644 --- a/src/NovaBelongsToDepend.php +++ b/src/NovaBelongsToDepend.php @@ -135,7 +135,12 @@ public function resolve($resource, $attribute = null) $foreign = $resource->{$this->attribute}(); $this->foreignKeyName = $foreign->getForeignKeyName(); - $value = $resource->{$this->attribute}()->withoutGlobalScopes()->first(); + if ($resource->relationLoaded($this->attribute)) { + $value = $resource->getRelation($this->attribute); + } else { + $value = $resource->{$this->attribute}()->withoutGlobalScopes()->first(); + } + if ($value) { $this->valueKey = $value->getKey(); $this->value = $this->formatDisplayValue($value);