@@ -234,17 +234,29 @@ public function getAttribute($key)
234
234
235
235
// This attribute matches an embedsOne or embedsMany relation so we need
236
236
// to return the relation results instead of the interal attributes.
237
- if ($ relations instanceof EmbedsOneOrMany or $ relations instanceof MorphTo ) {
237
+ if ($ relations instanceof EmbedsOneOrMany) {
238
238
// If the key already exists in the relationships array, it just means the
239
239
// relationship has already been loaded, so we'll just return it out of
240
240
// here because there is no need to query within the relations twice.
241
- if (array_key_exists ($ key , $ this ->relations ) && $ this -> relations [ $ key ] != null ) {
241
+ if (array_key_exists ($ key , $ this ->relations )) {
242
242
return $ this ->relations [$ key ];
243
243
}
244
244
245
245
// Get the relation results.
246
246
return $ this ->getRelationshipFromMethod ($ key , $ camelKey );
247
247
}
248
+
249
+ if ($ relations instanceof Relation) {
250
+ // If the key already exists in the relationships array, it just means the
251
+ // relationship has already been loaded, so we'll just return it out of
252
+ // here because there is no need to query within the relations twice.
253
+ if (array_key_exists ($ key , $ this ->relations ) && $ this ->relations [$ key ] !=null )
254
+ return $ this ->relations [$ key ];
255
+
256
+ // Get the relation results.
257
+ return $ this ->getRelationshipFromMethod ($ key , $ camelKey );
258
+ }
259
+
248
260
}
249
261
}
250
262
0 commit comments