Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/Database/Barry/Relations/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -47,6 +44,6 @@ public function getResults(): Collection
*/
public function addConstraints(): void
{
//
$this->query = $this->query->where($this->foreign_key, $this->parent->getKeyValue());
}
}
Loading