Skip to content

Commit

Permalink
Merge pull request #45 from spira/hotfix/elastic-index-fix
Browse files Browse the repository at this point in the history
Now checking if the result set for a nested model is empty before add…
  • Loading branch information
Jeremy Sik committed Feb 18, 2016
2 parents 6eca8d6 + 8058124 commit ec20c5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Model/Model/IndexedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public function getIndexDocumentData()
foreach ($this->indexRelations as $nestedModelName) {
/** @var IndexedModel|IndexedCollection $results */
$results = $this->$nestedModelName()->getResults();
if ($results instanceof Collection) {

if (is_null($results)) {
break;
} elseif ($results instanceof Collection) {
$nestedData = $results->map(function (IndexedModel $result) {
return array_intersect_key($result->attributesToArray(), $result->mappingProperties);
});
Expand Down

0 comments on commit ec20c5d

Please sign in to comment.