Skip to content

Commit b33e579

Browse files
committed
Update GenerateCommand.php
1 parent 6907992 commit b33e579

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/GenerateCommand.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,20 @@ private function writeControllerFile(Collection $routes, string $namespace): voi
173173

174174
private function writeMultiRouteControllerMethodExport(Collection $routes, string $path): void
175175
{
176+
$isInvokable = $routes->first()->hasInvokableController();
177+
176178
$this->appendContent($path, $this->view->make('wayfinder::multi-method', [
177179
'method' => $routes->first()->jsMethod(),
178180
'original_method' => $routes->first()->originalJsMethod(),
179181
'path' => $routes->first()->controllerPath(),
180182
'line' => $routes->first()->controllerMethodLineNumber(),
181183
'controller' => $routes->first()->controller(),
182-
'isInvokable' => $isInvokable = $routes->first()->hasInvokableController(),
184+
'isInvokable' => $isInvokable,
183185
'shouldExport' => ! $isInvokable,
184186
'withForm' => $this->option('with-form') ?? false,
185187
'routes' => $routes->map(fn ($r) => [
186188
'method' => $r->jsMethod(),
187-
'tempMethod' => $r->jsMethod().hash('xxh3', $r->uri()),
189+
'tempMethod' => $r->jsMethod().hash('xxh128', $r->uri()),
188190
'parameters' => $r->parameters(),
189191
'verbs' => $r->verbs(),
190192
'uri' => $r->uri(),
@@ -198,8 +200,8 @@ private function writeControllerMethodExport(Route $route, string $path): void
198200
'controller' => $route->controller(),
199201
'method' => $route->jsMethod(),
200202
'original_method' => $route->originalJsMethod(),
201-
'isInvokable' => $isInvokable = $route->hasInvokableController(),
202-
'shouldExport' => ! $isInvokable,
203+
'isInvokable' => $route->hasInvokableController(),
204+
'shouldExport' => ! $route->hasInvokableController(),
203205
'path' => $route->controllerPath(),
204206
'line' => $route->controllerMethodLineNumber(),
205207
'parameters' => $route->parameters(),
@@ -247,11 +249,11 @@ private function appendCommonImports(Collection $routes, string $path, string $n
247249
private function writeNamedMethodExport(Route $route, string $path): void
248250
{
249251
$this->appendContent($path, $this->view->make('wayfinder::method', [
250-
'controller' => $controller = $route->controller(),
252+
'controller' => $route->controller(),
251253
'method' => $route->namedMethod(),
252254
'original_method' => $route->originalJsMethod(),
253-
'isInvokable' => $isInvokable = $route->hasInvokableController(),
254-
'shouldExport' => (! $isInvokable) || str_contains($controller, '\\Closure'),
255+
'isInvokable' => $route->hasInvokableController(),
256+
'shouldExport' => ! $route->hasInvokableController() || str_contains($route->controller(), '\\Closure'),
255257
'path' => $route->controllerPath(),
256258
'line' => $route->controllerMethodLineNumber(),
257259
'parameters' => $route->parameters(),
@@ -274,7 +276,7 @@ private function writeBarrelFiles(array|Collection $children, string $parent): v
274276
$childKeys = $children->keys()->mapWithKeys(fn ($child) => [
275277
$child => [
276278
'safe' => TypeScript::safeMethod($child, 'Method'),
277-
'normalized' => (string) str($child)->whenContains('-', fn ($s) => $s->camel()),
279+
'normalized' => str($child)->whenContains('-', fn ($s) => $s->camel())->toString(),
278280
],
279281
]);
280282

0 commit comments

Comments
 (0)