Skip to content

Commit 407e252

Browse files
authored
Update MorphTo.php
1 parent d2cc27e commit 407e252

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/Illuminate/Database/Eloquent/Relations/MorphTo.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public function __construct(Builder $query, Model $parent, $foreignKey, $otherKe
5252

5353
parent::__construct($query, $parent, $foreignKey, $otherKey, $relation);
5454
}
55+
56+
/**
57+
* Get the results of the relationship.
58+
*
59+
* @return mixed
60+
*/
61+
public function getResults()
62+
{
63+
if ( ! $this->otherKey) return;
64+
65+
return $this->query->first();
66+
}
5567

5668
/**
5769
* Set the constraints for an eager load of the relation.

0 commit comments

Comments
 (0)