Commit ae621465 authored by Alexandre Butynski's avatar Alexandre Butynski

Fix infinite loo toArray() bug

parent 84f1df5e
......@@ -487,6 +487,7 @@ class EmbedsMany extends Relation {
// Attatch the parent relation to the embedded model.
$model->setRelation($this->foreignKey, $this->parent);
$model->setHidden(array_merge($model->getHidden(), array($this->foreignKey)));
$models[] = $model;
}
......
......@@ -342,6 +342,7 @@ class RelationsTest extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf('DateTime', $address->created_at);
$this->assertInstanceOf('DateTime', $address->updated_at);
$this->assertInstanceOf('User', $address->user);
$this->assertEmpty($address->relationsToArray()); // prevent infinite loop
$user = User::find($user->_id);
$user->addresses()->save(new Address(array('city' => 'Bruxelles')));
......
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