summaryrefslogtreecommitdiff
path: root/vendor/illuminate/database/Eloquent/Relations/BelongsTo.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/illuminate/database/Eloquent/Relations/BelongsTo.php')
-rwxr-xr-xvendor/illuminate/database/Eloquent/Relations/BelongsTo.php11
1 files changed, 4 insertions, 7 deletions
diff --git a/vendor/illuminate/database/Eloquent/Relations/BelongsTo.php b/vendor/illuminate/database/Eloquent/Relations/BelongsTo.php
index 4cd1f33254..3fbbe04047 100755
--- a/vendor/illuminate/database/Eloquent/Relations/BelongsTo.php
+++ b/vendor/illuminate/database/Eloquent/Relations/BelongsTo.php
@@ -75,6 +75,10 @@ class BelongsTo extends Relation
*/
public function getResults()
{
+ if (is_null($this->child->{$this->foreignKey})) {
+ return $this->getDefaultFor($this->parent);
+ }
+
return $this->query->first() ?: $this->getDefaultFor($this->parent);
}
@@ -132,13 +136,6 @@ class BelongsTo extends Relation
}
}
- // If there are no keys that were not null we will just return an array with null
- // so this query wont fail plus returns zero results, which should be what the
- // developer expects to happen in this situation. Otherwise we'll sort them.
- if (count($keys) === 0) {
- return [null];
- }
-
sort($keys);
return array_values(array_unique($keys));