From 748798700df05fa4b56f24e2037a8b6bcb42901e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0zni=20Burak=20Demirta=C5=9F?= Date: Sun, 26 Nov 2023 21:09:05 +0300 Subject: [PATCH] fix: route parameters issue about volt and livewire routes --- src/AutoRoute.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AutoRoute.php b/src/AutoRoute.php index fefae04..68b25e1 100644 --- a/src/AutoRoute.php +++ b/src/AutoRoute.php @@ -113,15 +113,15 @@ function () use ($controller, $only, $except, $patterns) { // Get endpoints and parameter patterns for Route [$endpoints, $routePatterns] = $this->getRouteValues($method, $patterns); - $endpoints = implode('/', $endpoints); + $endpoint = implode('/', $endpoints); $handler = [$classRef->getName(), $method->name]; - $routePath = ($path !== $this->mainMethod ? $path : '') . "/{$endpoints}"; + $routePath = ($path !== $this->mainMethod ? $path : '') . "/{$endpoint}"; // for volt if (str_starts_with($method->name, 'volt')) { if (class_exists(Volt::class) && $method->getReturnType()?->getName() === 'string') { - Volt::route($routePath, $method->invoke(new ($classRef->getName()))) + Volt::route($routePath, $method->invoke(new ($classRef->getName()), ...$endpoints)) ->where($routePatterns)->name("{$method->name}")->middleware($middleware); } @@ -134,7 +134,7 @@ function () use ($controller, $only, $except, $patterns) { continue; } - $handler = $method->invoke(new ($classRef->getName())); + $handler = $method->invoke(new ($classRef->getName()), ...$endpoints); if (!is_subclass_of($handler, Component::class)) { continue; }