Commit ab5b3844 authored by pi0's avatar pi0

Reformat and FIX

parent b0e2a184
...@@ -168,7 +168,7 @@ class Builder extends EloquentBuilder ...@@ -168,7 +168,7 @@ class Builder extends EloquentBuilder
// Get the number of related objects for each possible parent. // Get the number of related objects for each possible parent.
$relationCount = array_count_values(array_map(function ($id) { $relationCount = array_count_values(array_map(function ($id) {
return (string) $id; // Convert Back ObjectIds to Strings return (string)$id; // Convert Back ObjectIds to Strings
}, $query->pluck($relation->getHasCompareKey()))); }, $query->pluck($relation->getHasCompareKey())));
// Remove unwanted related objects based on the operator and count. // Remove unwanted related objects based on the operator and count.
...@@ -221,13 +221,17 @@ class Builder extends EloquentBuilder ...@@ -221,13 +221,17 @@ class Builder extends EloquentBuilder
if ($results instanceof Cursor) { if ($results instanceof Cursor) {
$results = iterator_to_array($results, false); $results = iterator_to_array($results, false);
return $this->model->hydrate($results); return $this->model->hydrate($results);
} // Convert Mongo BSONDocument to a single object. }
// Convert Mongo BSONDocument to a single object.
elseif ($results instanceof BSONDocument) { elseif ($results instanceof BSONDocument) {
$results = $results->getArrayCopy(); $results = $results->getArrayCopy();
return $this->model->newFromBuilder((array) $results); return $this->model->newFromBuilder((array)$results);
} // The result is a single object. }
// The result is a single object.
elseif (is_array($results) and array_key_exists('_id', $results)) { elseif (is_array($results) and array_key_exists('_id', $results)) {
return $this->model->newFromBuilder((array) $results); return $this->model->newFromBuilder((array)$results);
} }
return $results; return $results;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment