fix: allow prefixing route names

This commit is contained in:
Sami Mazouz 2024-10-25 13:46:53 +01:00
parent 38585cf478
commit 3af78c1a3d
No known key found for this signature in database
2 changed files with 9 additions and 0 deletions

View File

@ -207,6 +207,10 @@ class ApiServiceProvider extends AbstractServiceProvider
$path = rtrim("/$type$endpoint->path", '/');
$name = "$type.$endpoint->name";
if ($prefix = $resource->routeNamePrefix()) {
$name = "$prefix.$name";
}
$routes->addRoute($method, $path, $name, $factory->toApiResource($resource::class, $endpoint->name));
}
}

View File

@ -31,4 +31,9 @@ abstract class AbstractResource extends BaseResource
{
return $context->extractIdFromPath($context);
}
public function routeNamePrefix(): ?string
{
return null;
}
}