<?php

namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use ReCaptcha\ReCaptcha;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
        $recaptcha = new ReCaptcha('6LdbA-8nAAAAAPm9gKp_1Ooiwn9VwtKI1rFNXVNf');
        $response = $recaptcha->verify($value, $_SERVER['REMOTE_ADDR']);

        return $response->isSuccess();
        });
    }
}
