File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
src/Jenssegers/Mongodb/Eloquent Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 88use Jenssegers \Mongodb \Relations \EmbedsMany ;
99use Jenssegers \Mongodb \Relations \EmbedsOne ;
1010use Jenssegers \Mongodb \Relations \EmbedsOneOrMany ;
11+ use Jenssegers \Mongodb \Relations \MorphTo ;
1112use MongoDB \BSON \ObjectID ;
1213use MongoDB \BSON \UTCDateTime ;
1314use ReflectionMethod ;
@@ -233,11 +234,11 @@ public function getAttribute($key)
233234
234235 // This attribute matches an embedsOne or embedsMany relation so we need
235236 // to return the relation results instead of the interal attributes.
236- if ($ relations instanceof EmbedsOneOrMany) {
237+ if ($ relations instanceof EmbedsOneOrMany or $ relations instanceof MorphTo ) {
237238 // If the key already exists in the relationships array, it just means the
238239 // relationship has already been loaded, so we'll just return it out of
239240 // here because there is no need to query within the relations twice.
240- if (array_key_exists ($ key , $ this ->relations )) {
241+ if (array_key_exists ($ key , $ this ->relations ) && $ this -> relations [ $ key ] != null ) {
241242 return $ this ->relations [$ key ];
242243 }
243244
You can’t perform that action at this time.
0 commit comments