Skip to content

Commit 3fe0fb8

Browse files
authored
Update HasMany.php
1 parent a832737 commit 3fe0fb8

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/Database/Barry/Relations/HasMany.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,27 @@
44

55
namespace Bow\Database\Barry\Relations;
66

7+
use Bow\Database\Collection;
78
use Bow\Database\Barry\Model;
89
use Bow\Database\Barry\Relation;
9-
use Bow\Database\Collection;
10-
use Bow\Database\Exception\QueryBuilderException;
1110

1211
class HasMany extends Relation
1312
{
1413
/**
1514
* Create a new belongs to relationship instance.
1615
*
17-
* @param Model $related
18-
* @param Model $parent
19-
* @param string $foreign_key
20-
* @param string $local_key
21-
* @throws QueryBuilderException
16+
* @param Model $related
17+
* @param Model $parent
18+
* @param string $foreign_key
19+
* @param string $local_key
20+
* @param string $relation
2221
*/
2322
public function __construct(Model $related, Model $parent, string $foreign_key, string $local_key)
2423
{
25-
parent::__construct($related, $parent);
26-
2724
$this->local_key = $local_key;
2825
$this->foreign_key = $foreign_key;
2926

30-
$this->query = $this->query->where($this->foreign_key, $this->parent->getKeyValue());
27+
parent::__construct($related, $parent);
3128
}
3229

3330
/**
@@ -47,6 +44,6 @@ public function getResults(): Collection
4744
*/
4845
public function addConstraints(): void
4946
{
50-
//
47+
$this->query = $this->query->where($this->foreign_key, $this->parent->getKeyValue());
5148
}
5249
}

0 commit comments

Comments
 (0)