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 8
8
use Jenssegers \Mongodb \Relations \EmbedsMany ;
9
9
use Jenssegers \Mongodb \Relations \EmbedsOne ;
10
10
use Jenssegers \Mongodb \Relations \EmbedsOneOrMany ;
11
+ use Jenssegers \Mongodb \Relations \MorphTo ;
11
12
use MongoDB \BSON \ObjectID ;
12
13
use MongoDB \BSON \UTCDateTime ;
13
14
use ReflectionMethod ;
@@ -233,11 +234,11 @@ public function getAttribute($key)
233
234
234
235
// This attribute matches an embedsOne or embedsMany relation so we need
235
236
// to return the relation results instead of the interal attributes.
236
- if ($ relations instanceof EmbedsOneOrMany) {
237
+ if ($ relations instanceof EmbedsOneOrMany or $ relations instanceof MorphTo ) {
237
238
// If the key already exists in the relationships array, it just means the
238
239
// relationship has already been loaded, so we'll just return it out of
239
240
// 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 ) {
241
242
return $ this ->relations [$ key ];
242
243
}
243
244
You can’t perform that action at this time.
0 commit comments