├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json ├── resources └── views │ ├── .gitkeep │ └── forms │ └── components │ └── g-recaptcha.blade.php └── src ├── FilamentGRecaptchaFieldServiceProvider.php └── Forms └── Components └── GRecaptcha.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `filament-grecaptcha-field` will be documented in this file. 4 | 5 | ## v0.0.10 - 2025-03-21 6 | 7 | ### What's Changed 8 | 9 | * Fix: Use dispatchFormEvent method by @icaliman in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/16 10 | 11 | **Full Changelog**: https://github.com/AbanoubNassem/filament-grecaptcha-field/compare/v0.0.9...v0.0.10 12 | 13 | ## v0.0.9 - 2025-03-10 14 | 15 | ### What's Changed 16 | 17 | * Bump dependencies for Laravel 12 by @alkoumi in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/15 18 | 19 | ### New Contributors 20 | 21 | * @alkoumi made their first contribution in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/15 22 | 23 | **Full Changelog**: https://github.com/AbanoubNassem/filament-grecaptcha-field/compare/v0.0.8...v0.0.9 24 | 25 | ## v0.0.8 - 2025-02-07 26 | 27 | - Fix an issue where `captcha` value was not reset correctly. 28 | 29 | ## v0.0.7 - 2024-03-18 30 | 31 | - Add Laravel 11 Support 32 | 33 | ## v0.0.6 - 2023-08-20 34 | 35 | ### What's Changed 36 | 37 | - Add compatibility filament 3.x 🌝 by @ILDaviz in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/8 38 | 39 | ### New Contributors 40 | 41 | - @ILDaviz made their first contribution in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/8 42 | 43 | **Full Changelog**: https://github.com/AbanoubNassem/filament-grecaptcha-field/compare/v0.0.5...v0.0.6 44 | 45 | ## v0.0.5 - 2023-02-26 46 | 47 | ### What's Changed 48 | 49 | - Laravel 10 Support by @chengkangzai in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/7 50 | 51 | ### New Contributors 52 | 53 | - @chengkangzai made their first contribution in https://github.com/AbanoubNassem/filament-grecaptcha-field/pull/7 54 | 55 | **Full Changelog**: https://github.com/AbanoubNassem/filament-grecaptcha-field/compare/v0.0.4...v0.0.5 56 | 57 | ## v0.0.4 - 2022-12-16 58 | 59 | - Fix captcha disappear , when validation fails. 60 | 61 | ## v0.0.3 - 2022-11-30 62 | 63 | - Fix an issue where `captcha` value was not sent to the server. 64 | 65 | ## v0.0.2 66 | 67 | - refresh/reset gRecapcha field when filament-wizard-field updates, since when the wizard updates it wipes the state of the gRecapcha. 68 | 69 | ## v0.0.1 70 | 71 | - initial release 72 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) AbanoubNassem 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://github.com/AbanoubNassem/filament-grecaptcha-field) 2 | 3 | # Provides a Google reCaptcha V2 field for the Filament Forms(V2-V3), works in `Admin-Panel` and `Forntend-Forms`. 4 | 5 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/abanoubnassem/filament-grecaptcha-field.svg?style=flat-square)](https://packagist.org/packages/abanoubnassem/filament-grecaptcha-field) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/abanoubnassem/filament-grecaptcha-field.svg?style=flat-square)](https://packagist.org/packages/abanoubnassem/filament-grecaptcha-field) 7 | 8 | This plugin is built on top of [anhskohbo/no-captcha](https://github.com/anhskohbo/no-captcha) package. 9 | 10 | ## Installation 11 | 12 | You can install the package via composer: 13 | 14 | ```bash 15 | composer require abanoubnassem/filament-grecaptcha-field 16 | ``` 17 | 18 | Since the package depends on [anhskohbo/no-captcha](https://github.com/anhskohbo/no-captcha) package. You may publish the configuration by running: 19 | ```bash 20 | php artisan vendor:publish --provider="Anhskohbo\NoCaptcha\NoCaptchaServiceProvider" 21 | ``` 22 | 23 | 24 | ### Configuration 25 | 26 | Add `NOCAPTCHA_SECRET` and `NOCAPTCHA_SITEKEY` in **.env** file : 27 | 28 | ``` 29 | NOCAPTCHA_SECRET=secret-key 30 | NOCAPTCHA_SITEKEY=site-key 31 | ``` 32 | (You can obtain them from [here](https://www.google.com/recaptcha/admin)) 33 | 34 | ## Usage 35 | 36 | ```php 37 | use AbanoubNassem\FilamentGRecaptchaField\Forms\Components\GRecaptcha; 38 | 39 | // admin panel 40 | public static function form(Form $form): Form 41 | { 42 | return $form->schema([ 43 | ... 44 | GRecaptcha::make('captcha') 45 | ]); 46 | } 47 | 48 | //forntend-forms 49 | public $captcha = ''; // must be initialized 50 | protected function getFormSchema(): array 51 | { 52 | return [ 53 | .... 54 | GRecaptcha::make('captcha') 55 | ]; 56 | } 57 | ``` 58 | 59 | 60 | ## Changelog 61 | 62 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 63 | 64 | ## Security Vulnerabilities 65 | 66 | If you discover any security related issues, please create an issue. 67 | 68 | ## License 69 | 70 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 71 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "abanoubnassem/filament-grecaptcha-field", 3 | "description": "Provides a Google reCaptcha V2 field for the Filament Forms", 4 | "keywords": [ 5 | "AbanoubNassem", 6 | "laravel", 7 | "filament-grecaptcha-field", 8 | "recaptcha", 9 | "grecaptcha", 10 | "google", 11 | "captcha" 12 | ], 13 | "homepage": "https://github.com/abanoubnassem/filament-grecaptcha-field", 14 | "license": "MIT", 15 | "authors": [ 16 | { 17 | "name": "AbanoubNassem", 18 | "email": "abanoubnassemmousa@gmail.com", 19 | "role": "Developer" 20 | } 21 | ], 22 | "require": { 23 | "php": "^8.0|^8.1|^8.2|^8.3", 24 | "anhskohbo/no-captcha": "^3.4", 25 | "filament/forms": "^2.16|^3.0-stable|^3.2.51", 26 | "illuminate/contracts": "^9.0|^10.0|^11.0|^12.0", 27 | "spatie/laravel-package-tools": "^1.13.0" 28 | }, 29 | "require-dev": { 30 | "laravel/pint": "^1.0", 31 | "nunomaduro/collision": "^6.0", 32 | "orchestra/testbench": "^7.0||^8.22.0||^9.0.0||^10.0.0", 33 | "pestphp/pest": "^1.21||^2.1||^3.0", 34 | "pestphp/pest-plugin-laravel": "^1.1||^2.0||^3.0", 35 | "phpunit/phpunit": "^9.5" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "AbanoubNassem\\FilamentGRecaptchaField\\": "src", 40 | "AbanoubNassem\\FilamentGRecaptchaField\\Database\\Factories\\": "database/factories" 41 | } 42 | }, 43 | "autoload-dev": { 44 | "psr-4": { 45 | "AbanoubNassem\\FilamentGRecaptchaField\\Tests\\": "tests" 46 | } 47 | }, 48 | "scripts": { 49 | "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", 50 | "analyse": "vendor/bin/phpstan analyse", 51 | "test": "vendor/bin/pest", 52 | "test-coverage": "vendor/bin/pest --coverage", 53 | "format": "vendor/bin/pint" 54 | }, 55 | "config": { 56 | "sort-packages": true, 57 | "allow-plugins": { 58 | "pestphp/pest-plugin": true, 59 | "phpstan/extension-installer": true 60 | } 61 | }, 62 | "extra": { 63 | "laravel": { 64 | "providers": [ 65 | "AbanoubNassem\\FilamentGRecaptchaField\\FilamentGRecaptchaFieldServiceProvider" 66 | ], 67 | "aliases": { 68 | "FilamentGRecaptchaField": "AbanoubNassem\\FilamentGRecaptchaField\\Facades\\FilamentGRecaptchaField" 69 | } 70 | } 71 | }, 72 | "minimum-stability": "dev", 73 | "prefer-stable": true 74 | } 75 | -------------------------------------------------------------------------------- /resources/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbanoubNassem/filament-grecaptcha-field/6d3ca47f45be696c1721b2b7252e16bd5c34dc6e/resources/views/.gitkeep -------------------------------------------------------------------------------- /resources/views/forms/components/g-recaptcha.blade.php: -------------------------------------------------------------------------------- 1 | @once 2 | {!! NoCaptcha::renderJs(app()->getLocale()) !!} 3 | @endonce 4 | 5 | 20 | 21 | 35 |
47 | {!! NoCaptcha::display(['data-callback' => 'recaptchaCallback']) !!} 48 |
49 |
50 | -------------------------------------------------------------------------------- /src/FilamentGRecaptchaFieldServiceProvider.php: -------------------------------------------------------------------------------- 1 | name('filament-grecaptcha-field') 14 | ->hasViews(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Forms/Components/GRecaptcha.php: -------------------------------------------------------------------------------- 1 | rules('required|captcha'); 17 | $this->dehydrated(false); 18 | $this->label(''); 19 | } 20 | 21 | public function callBeforeStateDehydrated(): static 22 | { 23 | parent::callBeforeStateDehydrated(); 24 | 25 | if (method_exists($this->getLivewire(), 'dispatchFormEvent')) { 26 | $this->getLivewire()->dispatchFormEvent('resetCaptcha'); 27 | } else { 28 | $this->getLivewire()->emit('resetCaptcha'); 29 | } 30 | 31 | return $this; 32 | } 33 | } 34 | --------------------------------------------------------------------------------