Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerkretzmar committed Mar 20, 2024
1 parent 27f6f92 commit b13ebbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
7 changes: 1 addition & 6 deletions src/Ziggy.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ private function folioRoutes(): Collection

// Use already-registered named Folio routes (instead of searching for all relevant view files) to respect route caching
return collect(app(FolioRoutes::class)->routes())->map(function (array $route) use ($mountPaths) {
// TODO windows paths
// str_replace(DIRECTORY_SEPARATOR, '/', )
dump($route);
$uri = rtrim($route['baseUri'], '/') . str_replace($route['mountPath'], '', $route['path']);
$uri = str_replace('.blade.php', '', $uri);

Expand Down Expand Up @@ -276,9 +273,7 @@ private function folioRoutes(): Collection
}

$matchedView = new MatchedView(realpath($route['path']), [], $route['mountPath']);
$mountPath = Arr::first($mountPaths, fn ($mountPath) => realpath($mountPath->path) === realpath($route['mountPath']));
dump($matchedView);
dump($mountPath);
$mountPath = Arr::first($mountPaths, fn ($mountPath) => $mountPath->path === realpath($route['mountPath']));

return array_filter([
'uri' => $uri === '' ? '/' : trim($uri, '/'),
Expand Down
26 changes: 15 additions & 11 deletions tests/Unit/FolioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,25 @@ public function binding_fields()
File::ensureDirectoryExists(resource_path('views/pages/users'));
File::put(resource_path('views/pages/users/[User].blade.php'), '<?php Laravel\Folio\name("users.show");');
File::ensureDirectoryExists(resource_path('views/pages/posts'));
File::put(resource_path('views/pages/posts/[Post:slug].blade.php'), '<?php Laravel\Folio\name("posts.show");');
File::ensureDirectoryExists(resource_path('views/pages/teams'));
if (! str_starts_with(strtoupper(PHP_OS), 'WIN')) {
File::put(resource_path('views/pages/posts/[Post:slug].blade.php'), '<?php Laravel\Folio\name("posts.show");');
File::ensureDirectoryExists(resource_path('views/pages/teams'));
}
File::put(resource_path('views/pages/teams/[Team-uid].blade.php'), '<?php Laravel\Folio\name("teams.show");');

Folio::path(resource_path('views/pages'));

$this->assertSame([
'uri' => 'posts/{post}',
'methods' => ['GET'],
'parameters' => ['post'],
'bindings' => [
'post' => 'slug',
],
'middleware' => ['web'],
], (new Ziggy())->toArray()['routes']['posts.show']);
if (! str_starts_with(strtoupper(PHP_OS), 'WIN')) {
$this->assertSame([
'uri' => 'posts/{post}',
'methods' => ['GET'],
'parameters' => ['post'],
'bindings' => [
'post' => 'slug',
],
'middleware' => ['web'],
], (new Ziggy())->toArray()['routes']['posts.show']);
}
$this->assertSame([
'uri' => 'users/{user}',
'methods' => ['GET'],
Expand Down

0 comments on commit b13ebbb

Please sign in to comment.