From 672528e482d41741bcf094504541c9ba74871a33 Mon Sep 17 00:00:00 2001 From: Jamshed Javed Date: Tue, 20 Dec 2022 14:03:34 +0000 Subject: [PATCH] Add whereUlid(param) support for routing (#45372) --- .../CreatesRegularExpressionRouteConstraints.php | 11 +++++++++++ src/Illuminate/Support/Facades/Route.php | 1 + 2 files changed, 12 insertions(+) diff --git a/src/Illuminate/Routing/CreatesRegularExpressionRouteConstraints.php b/src/Illuminate/Routing/CreatesRegularExpressionRouteConstraints.php index e3a734bf1590..e170451465c9 100644 --- a/src/Illuminate/Routing/CreatesRegularExpressionRouteConstraints.php +++ b/src/Illuminate/Routing/CreatesRegularExpressionRouteConstraints.php @@ -39,6 +39,17 @@ public function whereNumber($parameters) return $this->assignExpressionToParameters($parameters, '[0-9]+'); } + /** + * Specify that the given route parameters must be ULIDs. + * + * @param array|string $parameters + * @return $this + */ + public function whereUlid($parameters) + { + return $this->assignExpressionToParameters($parameters, '[0-7][0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z]{25}'); + } + /** * Specify that the given route parameters must be UUIDs. * diff --git a/src/Illuminate/Support/Facades/Route.php b/src/Illuminate/Support/Facades/Route.php index 84d731b796b2..6fdaf6ee11bc 100755 --- a/src/Illuminate/Support/Facades/Route.php +++ b/src/Illuminate/Support/Facades/Route.php @@ -83,6 +83,7 @@ * @method static \Illuminate\Routing\RouteRegistrar whereAlpha(array|string $parameters) * @method static \Illuminate\Routing\RouteRegistrar whereAlphaNumeric(array|string $parameters) * @method static \Illuminate\Routing\RouteRegistrar whereNumber(array|string $parameters) + * @method static \Illuminate\Routing\RouteRegistrar whereUlid(array|string $parameters) * @method static \Illuminate\Routing\RouteRegistrar whereUuid(array|string $parameters) * @method static \Illuminate\Routing\RouteRegistrar whereIn(array|string $parameters, array $values) * @method static \Illuminate\Routing\RouteRegistrar as(string $value)