File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments