44
55namespace Bow \Database \Barry \Relations ;
66
7+ use Bow \Database \Collection ;
78use Bow \Database \Barry \Model ;
89use Bow \Database \Barry \Relation ;
9- use Bow \Database \Collection ;
10- use Bow \Database \Exception \QueryBuilderException ;
1110
1211class 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