From b98e2f43643526c79eb05eda6a621a5511f7e940 Mon Sep 17 00:00:00 2001 From: Kallef Alexandre Date: Mon, 29 Jul 2019 14:46:47 -0300 Subject: [PATCH] fix order foreach quando vindo null e retornando o create da categoria --- src/Endpoints/Category.php | 2 +- src/Model/Orders.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Endpoints/Category.php b/src/Endpoints/Category.php index 04e1bf7..48488f0 100755 --- a/src/Endpoints/Category.php +++ b/src/Endpoints/Category.php @@ -46,7 +46,7 @@ public function getCategories(int $level = 0, int $page = 1, int $perPage = 100) public function createCategories(Categories $categories) { - $this->request('POST', 'Category', [ + return $this->request('POST', 'Category', [ 'json' => $categories->getCategories()->toArray() ]); } diff --git a/src/Model/Orders.php b/src/Model/Orders.php index 3550592..4871dc1 100755 --- a/src/Model/Orders.php +++ b/src/Model/Orders.php @@ -98,8 +98,10 @@ public function __construct(\StdClass $data = null) $this->perPage = $data->PerPage; $this->total = $data->Total; - foreach ($data->Orders as $order) { - $this->orders->push(new Order($order)); + if ($data->Orders) { + foreach ($data->Orders as $order) { + $this->orders->push(new Order($order)); + } } } }