dizatech/cutlet-recaptcha

A package to use google recaptcha v2 with component and rule in laravel apps.

v1.0.3 2023-09-02 13:13 UTC

This package is auto-updated.

Last update: 2024-12-01 00:08:22 UTC


README

GitHub issues GitHub stars GitHub forks GitHub license

Installation


composer require va/cutlet-recaptcha

Publish Config file


php artisan vendor:publish --tag=cutlet-recaptcha

Usage

Set the values for google api in .env file:

GOOGLE_RECAPTCHA_SITE_KEY=
GOOGLE_RECAPTCHA_SECRET_KEY=

You can add this tag in blade files:

<x-cutlet-recaptcha :has-error="$errors->has('g-recaptcha-response')"></x-cutlet-recaptcha>

and in the validation parts:

protected function validateLogin(Request $request)
    {
        $request->validate([
            $this->username() => ['required', 'string'],
            'password' => ['required', 'string'],
            'g-recaptcha-response' => ['required', 'cutlet_recaptcha']
            ]);
    }

and you can customize the language and validation message in config file;

return [
    'language' => 'fa',
    'site_key' => env('GOOGLE_RECAPTCAH_SITE_KEY'),
    'secret_key' => env('GOOGLE_RECAPTCAH_SECRET_KEY'),
    'message' => 'شما به عنوان ربات تشخیص داده شده‌اید'
];

Requirements:

  • PHP v7.0 or above
  • Laravel v7.0 or above