From b1d38d005a8c83de90a87893cca5e84ec764c9fb Mon Sep 17 00:00:00 2001 From: Sebastian Brown Date: Tue, 11 Nov 2025 11:11:50 -0600 Subject: [PATCH 1/2] fix: preserve debug flag when creating new builder instances via newInstance() - fix: preserve debug flag by passing $this->debug to client - feat: default setDebug() to true when no argument is provided --- src/Api/Client.php | 2 +- src/Support/Builder.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Api/Client.php b/src/Api/Client.php index 2a04f7e..61f2c10 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -291,7 +291,7 @@ protected function setConfigs(array $configs): self /** * Set debug */ - public function setDebug(bool $debug): self + public function setDebug(bool $debug = true): self { $this->debug = $debug; diff --git a/src/Support/Builder.php b/src/Support/Builder.php index 124ecc4..d03943c 100644 --- a/src/Support/Builder.php +++ b/src/Support/Builder.php @@ -187,7 +187,7 @@ public function get(array|string $properties = ['*'], ?string $extra = null): Co ->only($properties) ->toArray() ) - ->setClient($this->getClient()->setDebug(false))) + ->setClient($this->getClient()->setDebug($this->debug))) ->setLinks($links) ->setPagination(count: $count, page: $page, pages: $pages, pageSize: $pageSize) // If never a collection, only return the first @@ -287,9 +287,11 @@ public function newInstance(): self ->setClass($this->class) ->setClient($this->getClient()) ->setParent($this->parentModel) + ->setDebug($this->debug) : (new static()) ->setClient($this->getClient()) - ->setParent($this->parentModel); + ->setParent($this->parentModel) + ->setDebug($this->debug); } /** From 9ba868d632d03aeb96c99b741d4a62d03d108c34 Mon Sep 17 00:00:00 2001 From: Sebastian Brown Date: Tue, 11 Nov 2025 13:23:16 -0600 Subject: [PATCH 2/2] refactor: rename debug() to setDebug() for consistency with Client --- src/Support/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/Builder.php b/src/Support/Builder.php index d03943c..2618584 100644 --- a/src/Support/Builder.php +++ b/src/Support/Builder.php @@ -142,7 +142,7 @@ public function create(array $attributes): Model * * This is reset to false after the request */ - public function debug(bool $debug = true): self + public function setDebug(bool $debug = true): self { $this->debug = $debug;