%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/demo/app/Rules/
Upload File :
Create Path :
Current File : //www/loslex/demo/app/Rules/Recaptcha.php

<?php

namespace App\Rules;

use Closure;
use Illuminate\Support\Facades\Http;
use Illuminate\Contracts\Validation\ValidationRule;

class Recaptcha implements ValidationRule
{
    /**
     * Run the validation rule.
     *
     * @param  \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        $g_response = Http::asForm()->post("https://www.google.com/recaptcha/api/siteverify", [
            'secret' => config('services.recaptcha.secret_key'),
            'response' => $value,
            'remoteip' => \request()->ip()
        ]);
        if (!$g_response->json('success')) {
            $fail("The {$attribute} is invalid");
        }
    }
}

Zerion Mini Shell 1.0