From e2464318a49895972c7146ee28b9299da3649f8b Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 25 Oct 2016 16:44:09 +0200 Subject: [PATCH 1/2] fix action helper (#23) --- CHANGELOG.md | 4 ++++ src/Link.php | 4 ++-- tests/LinkTest.php | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40019e3..c43ed11 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All Notable changes to `laravel-menu` will be documented in this file +## 2.0.1 - 2016-10-25 + +- Fix `Link`'s action helper so it can take the same type of parameters as the laravel `action` helper + ## 2.0.0 - Upgraded `spatie/menu` to 2.0. diff --git a/src/Link.php b/src/Link.php index 8110769..9cc19d4 100644 --- a/src/Link.php +++ b/src/Link.php @@ -25,12 +25,12 @@ public static function toUrl(string $path, string $text, array $parameters = [], /** * @param string $action * @param string $text - * @param array $parameters + * @param mixed $parameters * @param bool $absolute * * @return static */ - public static function toAction(string $action, string $text, array $parameters = [], bool $absolute = true) + public static function toAction(string $action, string $text, $parameters = [], bool $absolute = true) { return static::to(action($action, $parameters, $absolute), $text); } diff --git a/tests/LinkTest.php b/tests/LinkTest.php index 7119a3c..0d1bd7e 100644 --- a/tests/LinkTest.php +++ b/tests/LinkTest.php @@ -52,7 +52,16 @@ public function it_can_be_created_for_an_action() } /** @test */ - public function it_can_be_created_for_an_action_with_parameters() + public function it_can_be_created_for_an_action_with_a_parameter() + { + $this->assertRenders( + 'Post #1', + Link::toAction(DummyController::class.'@post', 'Post #1', 1) + ); + } + + /** @test */ + public function it_can_be_created_for_an_action_with_an_array_of_parameters() { $this->assertRenders( 'Post #1', From 8e14914d5a5d18f41f670b901270ad9e58582732 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 25 Oct 2016 16:44:28 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c43ed11..69f7268 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All Notable changes to `laravel-menu` will be documented in this file ## 2.0.1 - 2016-10-25 -- Fix `Link`'s action helper so it can take the same type of parameters as the laravel `action` helper +- Fix `Link`'s action helper so it can take the same type of parameters as the Laravel's `action` helper ## 2.0.0