Skip to content

Commit 0aa487d

Browse files
authored
Merge pull request #8 from MacsiDigital/3.0
3.0 To master
2 parents fc7f291 + 84d2cc3 commit 0aa487d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/Support/Builder.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,26 +273,20 @@ public function all()
273273

274274
}
275275

276-
public function get()
276+
public function get($type = 'get')
277277
{
278278
if($this->resource->beforeQuery($this) === false){
279279
return;
280280
}
281281
return $this->handleResponse($this->sendRequest('get', [
282282
$this->retreiveEndPoint('get'),
283283
$this->addPagination($this->combineQueries())
284-
]), 'get');
284+
]), $type);
285285
}
286286

287287
public function getOne()
288288
{
289-
if($this->resource->beforeQuery($this) === false){
290-
return;
291-
}
292-
return $this->handleResponse($this->sendRequest('get', [
293-
$this->retreiveEndPoint('get'),
294-
$this->addPagination($this->combineQueries())
295-
]), 'individual');
289+
return $this->get('individual');
296290
}
297291

298292
public function post($attributes, $type="individual")

src/Support/ResultSet.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ protected function populate($array)
116116
$this->incrementTotalDownloads(count($array[$this->resource->getApiMultipleDataField()]));
117117
return $this;
118118
} else{
119-
foreach($array[$this->resource->getApiMultipleDataField()] as $object){
120-
$this->items->push($this->resource->newFromBuilder($this->resource->passOnAttributes($object)));
121-
$this->incrementTotalDownloads();
122-
}
119+
if(isset($array[$this->resource->getApiMultipleDataField()])){
120+
foreach($array[$this->resource->getApiMultipleDataField()] as $object){
121+
$this->items->push($this->resource->newFromBuilder($this->resource->passOnAttributes($object)));
122+
$this->incrementTotalDownloads();
123+
}
124+
}
123125
}
124126
}
125127

src/Traits/InteractsWithAPI.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected function performUpdate(Builder $query)
387387
}
388388

389389
$resource = (new $this->updateResource)->fill($this, 'update');
390-
390+
391391
if($resource->getAttributes() != []){
392392

393393
$validator = $resource->validate();
@@ -613,6 +613,11 @@ public function fresh()
613613
return;
614614
}
615615

616+
if(method_exists($this, 'find'))
617+
{
618+
return $this->find($this->getKey());
619+
}
620+
616621
return $this->newQuery()->find($this->getKey());
617622
}
618623

0 commit comments

Comments
 (0)