diff --git a/src/Illuminate/Routing/UrlGenerator.php b/src/Illuminate/Routing/UrlGenerator.php index 26a964b95e87..c055b350c02e 100755 --- a/src/Illuminate/Routing/UrlGenerator.php +++ b/src/Illuminate/Routing/UrlGenerator.php @@ -305,6 +305,8 @@ public function formatScheme($secure) */ public function signedRoute($name, $parameters = [], $expiration = null) { + $parameters = $this->formatParameters($parameters); + if ($expiration) { $parameters = $parameters + ['expires' => $this->availableAt($expiration)]; } diff --git a/tests/Integration/Routing/UrlSigningTest.php b/tests/Integration/Routing/UrlSigningTest.php index 2ac0edd3f5e6..4cb784a33b27 100644 --- a/tests/Integration/Routing/UrlSigningTest.php +++ b/tests/Integration/Routing/UrlSigningTest.php @@ -7,6 +7,7 @@ use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\Route; +use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Routing\Middleware\ValidateSignature; /** @@ -62,4 +63,38 @@ public function test_signed_middleware_with_invalid_url() $response = $this->get($url); $response->assertStatus(401); } + + public function test_signed_middleware_with_routable_parameter() + { + $model = new RoutableInterfaceStub; + $model->routable = 'routable'; + + Route::get('/foo/{bar}', function (Request $request, $routable) { + return $request->hasValidSignature() ? $routable : 'invalid'; + })->name('foo'); + + $this->assertTrue(is_string($url = URL::signedRoute('foo', $model))); + $this->assertEquals('routable', $this->get($url)->original); + } +} + + +class RoutableInterfaceStub implements UrlRoutable +{ + public $key; + + public function getRouteKey() + { + return $this->{$this->getRouteKeyName()}; + } + + public function getRouteKeyName() + { + return 'routable'; + } + + public function resolveRouteBinding($routeKey) + { + // + } }