From 1d03dbdb094336cdba15250d4e53de9005d98270 Mon Sep 17 00:00:00 2001 From: Daniel Neykov Date: Thu, 12 Dec 2019 11:09:54 +0200 Subject: [PATCH 1/2] Update Route.php Using different column than `id` to fetch Resources breaks if numbers starts from zero. --- src/Routing/Route.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Routing/Route.php b/src/Routing/Route.php index 6f2a3300..fc7b1025 100644 --- a/src/Routing/Route.php +++ b/src/Routing/Route.php @@ -83,19 +83,21 @@ public function __construct(ResolverInterface $resolver, ?IlluminateRoute $route public function substituteBindings(StoreInterface $store): void { /** Cache the ID values so that we still have access to them. */ - $this->resourceId = $this->getResourceId() ?: false; - $this->processId = $this->getProcessId() ?: false; - + $tempResourceId = $this->getResourceId(); + $tempProcessId = $this->getProcessId(); + $this->resourceId = isset($tempResourceId) ? $tempResourceId : false; + $this->processId = isset($tempProcessId) ? $tempProcessId : false; + /** Bind the domain record. */ - if ($this->resourceId) { + if (!empty($this->resourceId) || '0' === $this->resourceId) { $this->route->setParameter( ResourceRegistrar::PARAM_RESOURCE_ID, $store->findOrFail($this->getResourceType(), $this->resourceId) ); } - + /** Bind the async process. */ - if ($this->processId) { + if (!empty($this->processId) || '0' === $this->processId) { $this->route->setParameter( ResourceRegistrar::PARAM_PROCESS_ID, $store->findOrFail($this->getProcessType(), $this->processId) From 25aaee7ffe4d26d3079eeee815ee522890f740ba Mon Sep 17 00:00:00 2001 From: Daniel Neykov Date: Thu, 12 Dec 2019 11:12:23 +0200 Subject: [PATCH 2/2] Update IdentifiableTrait.php Using different column than id to fetch Resources breaks if numbers starts from zero. --- src/Object/IdentifiableTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Object/IdentifiableTrait.php b/src/Object/IdentifiableTrait.php index 5583354d..219bd83d 100644 --- a/src/Object/IdentifiableTrait.php +++ b/src/Object/IdentifiableTrait.php @@ -75,7 +75,7 @@ public function getId() throw new RuntimeException('Id member is not a string.'); } - if (empty($id)) { + if (empty($id) && '0' !== $id) { throw new RuntimeException('Id member is an empty string.'); }