Skip to content

Commit df6729f

Browse files
committed
first commit
0 parents  commit df6729f

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "test-hook",
3+
"description": "This is my first hook.",
4+
"require": {
5+
"larapack/hooks": "~1.0"
6+
},
7+
"autoload": {
8+
"psr-4": {
9+
"TestHook\\": "src/"
10+
}
11+
},
12+
"extra": {
13+
"hook": {
14+
"providers": [
15+
"TestHook\\TestHookServiceProvider"
16+
]
17+
}
18+
}
19+
}

src/TestHookServiceProvider.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace TestHook;
4+
5+
use Illuminate\Events\Dispatcher;
6+
use Illuminate\Support\ServiceProvider;
7+
8+
class TestHookServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Bootstrap any application services.
12+
*
13+
* @return void
14+
*/
15+
public function boot()
16+
{
17+
//
18+
}
19+
20+
/**
21+
* Register any application services.
22+
*
23+
* @return void
24+
*/
25+
public function register()
26+
{
27+
// Add routers
28+
app('router')->get('test', function () {
29+
return 'Hello world!';
30+
});
31+
32+
// Add routes with Voyager's prefix (group)
33+
app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {
34+
$router->get('test', function () {
35+
return 'Hello possibly not-logged-in user!';
36+
});
37+
});
38+
39+
// Add routes behind Voyager authentication
40+
app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {
41+
$router->get('test-with-login', function () {
42+
return 'Hello logged-in user!';
43+
})->name('test');
44+
});
45+
}
46+
}

0 commit comments

Comments
 (0)