Permalink
Browse files

When using eager load, some relation has no records and will be set

'null'.
  • Loading branch information...
Tong Jishi
Tong Jishi committed May 12, 2016
1 parent 579782d commit 89083c1ab4f8acca85f52de33121c1dd2d45e739
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/ElasticquentTrait.php
@@ -712,9 +712,12 @@ public static function loadRelationsAttributesRecursive(Model $model)
if ($relation instanceof Relation) {
// Check if the relation field is single model or collections
if (!static::isMultiLevelArray($value)) {
if (is_array($value) && !static::isMultiLevelArray($value)) {
$value = [$value];
}
if(is_null($value)){
$value = [];
}
$models = static::hydrateRecursive($relation->getModel(), $value, $relation);

0 comments on commit 89083c1

Please sign in to comment.