Commit 128eb7b5 authored by Jens Segers's avatar Jens Segers

Fix embedsMany related model, fixes #138

parent 234cfd51
...@@ -79,7 +79,9 @@ abstract class Model extends \Jenssegers\Eloquent\Model { ...@@ -79,7 +79,9 @@ abstract class Model extends \Jenssegers\Eloquent\Model {
$query = $this->newQuery(); $query = $this->newQuery();
return new EmbedsMany($query, $this, $localKey, $foreignKey, $relation); $instance = new $related;
return new EmbedsMany($query, $this, $instance, $localKey, $foreignKey, $relation);
} }
/** /**
......
...@@ -39,13 +39,16 @@ class EmbedsMany extends Relation { ...@@ -39,13 +39,16 @@ class EmbedsMany extends Relation {
* @param string $relation * @param string $relation
* @return void * @return void
*/ */
public function __construct(Builder $query, Model $parent, $localKey, $foreignKey, $relation) public function __construct(Builder $query, Model $parent, Model $related, $localKey, $foreignKey, $relation)
{ {
$this->query = $query;
$this->parent = $parent;
$this->related = $related;
$this->localKey = $localKey; $this->localKey = $localKey;
$this->foreignKey = $foreignKey; $this->foreignKey = $foreignKey;
$this->relation = $relation; $this->relation = $relation;
parent::__construct($query, $parent); $this->addConstraints();
} }
/** /**
......
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