Skip to content

Commit 9f8bae6

Browse files
committed
fix make on hasMany
1 parent 67cb418 commit 9f8bae6

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Support/Relations/HasMany.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ public function __construct($related, $owner, $name, $field, $updateFields = [])
2525
$this->boot();
2626
}
2727

28-
protected function setUpdateFields($fields)
28+
protected function setUpdateFields($fields)
2929
{
3030
$this->updateFields = $fields;
3131
if($this->owner->hasKey()){
3232
$this->updateFields[$this->field] = $this->owner->getKey();
3333
}
3434
}
3535

36-
public function hasUpdateFields()
36+
public function hasUpdateFields()
3737
{
3838
return $this->updateFields != [];
3939
}
4040

41-
public function getUpdateKeys()
41+
public function getUpdateKeys()
4242
{
4343
return array_keys($this->updateFields);
4444
}
@@ -56,7 +56,7 @@ public function updateFields($item){
5656
return $item;
5757
}
5858

59-
public function boot()
59+
public function boot()
6060
{
6161
if(array_key_exists($this->name, $this->owner->getAttributes())){
6262
$this->hydrate($this->owner->getAttributes()[$this->name]);
@@ -75,7 +75,7 @@ public function boot()
7575
}
7676
}
7777

78-
protected function hydrate($array)
78+
protected function hydrate($array)
7979
{
8080
$collection = new Collection;
8181
if($array != []){
@@ -86,15 +86,15 @@ protected function hydrate($array)
8686
$this->relation = $collection;
8787
}
8888

89-
public function empty()
89+
public function empty()
9090
{
9191
$this->relation = new Collection;
9292
return $this;
9393
}
9494

9595
public function make($data)
9696
{
97-
$this->attach($this->newRelation($this->updateFields($data)));
97+
$this->attach(($object = $this->newRelation($this->updateFields($data))));
9898
return $object;
9999
}
100100

@@ -106,7 +106,7 @@ public function attach($object)
106106

107107
public function detach($object)
108108
{
109-
109+
110110
}
111111

112112
public function save(object $object)
@@ -140,25 +140,25 @@ public function createMany(array $data)
140140
return $this;
141141
}
142142

143-
public function getResults()
143+
public function getResults()
144144
{
145145
if($this->relation->count() == 0){
146146
$this->getRelationFromApi();
147-
}
147+
}
148148
return $this->relation;
149149
}
150150

151-
public function first()
151+
public function first()
152152
{
153153
return $this->getResults()->first()->fresh();
154154
}
155155

156-
public function last()
156+
public function last()
157157
{
158158
return $this->getResults()->last()->fresh();
159159
}
160160

161-
public function getRelationFromApi()
161+
public function getRelationFromApi()
162162
{
163163
$this->relation = $this->newRelation($this->updateFields([]))->setPassOnAttributes($this->getUpdateKeys())->all();
164164
if($this->hasUpdateFields()){
@@ -169,7 +169,7 @@ public function getRelationFromApi()
169169
return $this;
170170
}
171171

172-
public function nextPage()
172+
public function nextPage()
173173
{
174174
$this->relation = $this->relation->nextPage();
175175
if($this->hasUpdateFields()){
@@ -179,7 +179,7 @@ public function nextPage()
179179
}
180180
}
181181

182-
public function prevPage()
182+
public function prevPage()
183183
{
184184
$this->relation = $this->relation->prevPage();
185185
if($this->hasUpdateFields()){
@@ -203,9 +203,9 @@ public function __call($method, $parameters)
203203
} else {
204204
$relation = $this->newRelation($this->updateFields([]))->setPassOnAttributes($this->getUpdateKeys());
205205
return $this->forwardCallTo($relation, $method, $parameters);
206-
}
206+
}
207207
}
208208

209209
// Be good to add these:- findOrNew, firstOrNew, firstOrCreate and updateOrCreate
210210

211-
}
211+
}

0 commit comments

Comments
 (0)