-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit df6729f
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace TestHook; | ||
|
||
use Illuminate\Events\Dispatcher; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class TestHookServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// Add routers | ||
app('router')->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'); | ||
}); | ||
} | ||
} |