=========
Laravel reCaptcha Middleware it's a Composer package created to help us to validate reCaptcha payloads during the initial steps of request lifecycle.
Add the following line to the require section of composer.json:
{
"require": {
"henriqueramos/recaptcha_middleware": "dev-master"
}
}- Run
php artisan vendor:publish --provider="RamosHenrique\reCaptchaMiddleware". - In your .env, enter your reCAPTCHA private key as value for
RECAPTCHA_MIDDLEWARE_SECRET_KEYandRECAPTCHA_MIDDLEWARE_RESPONSE_TYPEasjsonorhtml.
Add into your selected routes the middleware recaptcha_middleware.
$this->router->post(
'myProtectedRoute',
[
'as' => 'my.protected.route',
'uses' => 'ProtectedRouteController@necessaryMethod',
]
)
->middleware('recaptcha_middleware');