Skip to content

Commit 5b97609

Browse files
committed
wip
1 parent 84be2c6 commit 5b97609

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

src/GenerateCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public function handle()
7878
if (! $this->option('skip-routes')) {
7979
$this->files->deleteDirectory($this->base());
8080

81-
$named = $routes->filter(
82-
fn (Route $route) => $route->name() && ! Str::endsWith($route->name(), '.') && ! Str::startsWith($route->name(), 'generated::')
83-
)->groupBy(fn (Route $route) => $route->name());
81+
$named = $routes->filter(fn (Route $route) => $route->name())->groupBy(fn (Route $route) => $route->name());
8482

8583
$named->each($this->writeNamedFile(...));
8684
$named->undot()->each($this->writeBarrelFiles(...));

src/Route.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ public function domain(): ?string
121121

122122
public function name(): ?string
123123
{
124-
return $this->base->getName();
124+
$name = $this->base->getName();
125+
126+
if (! $name || Str::endsWith($name, '.') || Str::startsWith($name, 'generated::')) {
127+
return null;
128+
}
129+
130+
if (str_contains($name, '::')) {
131+
return 'namespaced.'.str_replace('::', '.', $name);
132+
}
133+
134+
return $name;
125135
}
126136

127137
public function controllerPath(): string

tests/NamedspacedRoute.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, it } from "vitest";
2+
import { store } from "../workbench/resources/js/routes/namespaced/my-package";
3+
4+
it("can access a namespaced route", () => {
5+
expect(store.url()).toBe("/package-route");
6+
expect(store()).toEqual({
7+
url: "/package-route",
8+
method: "get",
9+
});
10+
});

workbench/routes/web.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070

7171
Route::get('/anonymous-middleware', [AnonymousMiddlewareController::class, 'show']);
7272

73+
Route::get('/package-route', function () {
74+
//
75+
})->name('my-package::store');
76+
7377
Route::prefix('/api/v1')->name('api.v1.')->group(function () {
7478
Route::get('/tasks', fn () => 'ok')->name('tasks');
7579

0 commit comments

Comments
 (0)