Add the package to your project via composer.
composer require httpoz/hooks
Run this to publish the package's migrations
php artisan vendor:publish --provider="HttpOz\Hook\HookServiceProvider"
This package comes with ValidateHookMiddleware
. You need to add it to your app/Http/Kernel.php
.
<?php
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
// ...
'validateHook' => \HttpOz\Hook\Http\Middleware\ValidateHookMiddleware::class,
];
Now you can add this middleware to your routes. You will also need the prefix, you can call it anything you want but the hook id itself should be the second segment in your url.
<?php
// Route group
Route::group(['prefix' => 'hooks/{hook}', 'middleware' => 'validateHook'], function(){
Route::resource('notification', 'NotificationController');
});