diff --git a/src/Database/Barry/Relations/HasMany.php b/src/Database/Barry/Relations/HasMany.php index b24f2286..43ec1bda 100644 --- a/src/Database/Barry/Relations/HasMany.php +++ b/src/Database/Barry/Relations/HasMany.php @@ -4,30 +4,27 @@ namespace Bow\Database\Barry\Relations; +use Bow\Database\Collection; use Bow\Database\Barry\Model; use Bow\Database\Barry\Relation; -use Bow\Database\Collection; -use Bow\Database\Exception\QueryBuilderException; class HasMany extends Relation { /** * Create a new belongs to relationship instance. * - * @param Model $related - * @param Model $parent - * @param string $foreign_key - * @param string $local_key - * @throws QueryBuilderException + * @param Model $related + * @param Model $parent + * @param string $foreign_key + * @param string $local_key + * @param string $relation */ public function __construct(Model $related, Model $parent, string $foreign_key, string $local_key) { - parent::__construct($related, $parent); - $this->local_key = $local_key; $this->foreign_key = $foreign_key; - $this->query = $this->query->where($this->foreign_key, $this->parent->getKeyValue()); + parent::__construct($related, $parent); } /** @@ -47,6 +44,6 @@ public function getResults(): Collection */ public function addConstraints(): void { - // + $this->query = $this->query->where($this->foreign_key, $this->parent->getKeyValue()); } }