Skip to content

Commit af92fd4

Browse files
committed
Merge branch 'master' into 3.0
2 parents 390e515 + e7a4544 commit af92fd4

File tree

3 files changed

+66
-25
lines changed

3 files changed

+66
-25
lines changed

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,52 @@
22

33
All notable changes to `laravel-api-client` will be documented in this file
44

5+
## 3.0.4 - 2020-05-29
6+
7+
- Bug fix, getKey function went into infinite loop
8+
9+
## 3.0.3 - 2020-05-29
10+
11+
- Bug fix, error on deletion.
12+
13+
## 3.0.2 - 2020-05-29
14+
15+
- Bug fix, on save or deletion the populated model was not being returned.
16+
17+
## 3.0.0 - 2020-05-27
18+
19+
- The Laravel 7.0 Version
20+
- Use the Laravel Http client.
21+
22+
## 2.0.5 - 2020-05-29
23+
24+
- Bug fix, getKey function went into infinite loop
25+
26+
## 2.0.4 - 2020-05-29
27+
28+
- Bug fix, error on deletion.
29+
30+
## 2.0.3 - 2020-05-29
31+
32+
- Bug fix, on save or deletion the populated model was not being returned.
33+
534
## 2.0.0 - 2020-05-27
635

736
- The Laravel 6.0 Version
837
- Mainly updates to use newer Laravel Model Attribute casting.
938

39+
## 1.0.17 - 2020-05-29
40+
41+
- Bug fix, getKey function went into infinite loop
42+
43+
## 1.0.16 - 2020-05-29
44+
45+
- Bug fix, error on deletion.
46+
47+
## 1.0.14 - 2020-05-29
48+
49+
- Bug fix, on save or deletion the populated model was not being returned.
50+
1051
## 1.0.12 - 2020-05-27
1152

1253
- Updates to many things.

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+
}

src/Support/Relations/HasOne.php

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

28-
public function boot()
28+
public function boot()
2929
{
3030
if(array_key_exists($this->name, $this->owner->getAttributes())){
3131
$this->hydrate($this->owner->getAttributes()[$this->name]);
@@ -42,7 +42,7 @@ public function boot()
4242
}
4343
}
4444

45-
protected function hydrate($data)
45+
protected function hydrate($data)
4646
{
4747
if($data != []){
4848
if($this->owner->hasKey()){
@@ -54,7 +54,7 @@ protected function hydrate($data)
5454
}
5555
}
5656

57-
public function empty()
57+
public function empty()
5858
{
5959
$this->relation = null;
6060
return $this;
@@ -73,21 +73,21 @@ public function save(object $object)
7373
throw new IncorrectRelationshipModel($this->related, $object);
7474
}
7575
} else {
76-
throw new NotAPersistableModel($this->owner, $this->related);
76+
throw new NotAPersistableModel($this->owner, $this->related);
7777
}
7878
}
7979
throw new RelationAlreadyExistsException($this->owner, $this->related);
8080
}
8181

82-
public function getResults()
82+
public function getResults()
8383
{
8484
if(empty($this->relation)){
8585
$this->getRelationFromApi();
86-
}
86+
}
8787
return $this->relation;
8888
}
8989

90-
public function getRelationFromApi()
90+
public function getRelationFromApi()
9191
{
9292
$this->relation = $this->related->newInstance([$this->field => $this->owner->getKey()])->getOne();
9393
if($this->field != null && $this->owner->hasKey() && $this->relation != null){
@@ -108,4 +108,4 @@ public function make($data)
108108

109109
// Be good to add these:- findOrNew, updateOrCreate
110110

111-
}
111+
}

0 commit comments

Comments
 (0)