From df6729fc0768c379b78c539067dc81f26ed3c520 Mon Sep 17 00:00:00 2001 From: Mark Topper Date: Tue, 22 Aug 2017 19:37:22 +0200 Subject: [PATCH] first commit --- composer.json | 19 ++++++++++++++ src/TestHookServiceProvider.php | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 composer.json create mode 100644 src/TestHookServiceProvider.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9a472bb --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "test-hook", + "description": "This is my first hook.", + "require": { + "larapack/hooks": "~1.0" + }, + "autoload": { + "psr-4": { + "TestHook\\": "src/" + } + }, + "extra": { + "hook": { + "providers": [ + "TestHook\\TestHookServiceProvider" + ] + } + } +} \ No newline at end of file diff --git a/src/TestHookServiceProvider.php b/src/TestHookServiceProvider.php new file mode 100644 index 0000000..4506b27 --- /dev/null +++ b/src/TestHookServiceProvider.php @@ -0,0 +1,46 @@ +get('test', function () { + return 'Hello world!'; + }); + + // Add routes with Voyager's prefix (group) + app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) { + $router->get('test', function () { + return 'Hello possibly not-logged-in user!'; + }); + }); + + // Add routes behind Voyager authentication + app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) { + $router->get('test-with-login', function () { + return 'Hello logged-in user!'; + })->name('test'); + }); + } +}