PHP code example of ghorbani / filament-arcaptcha-field

1. Go to this page and download the library: Download ghorbani/filament-arcaptcha-field library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ghorbani / filament-arcaptcha-field example snippets


use Ghorbani\FilamentArCaptchaField\Forms\Components\ArCaptcha;

public static function form(Form $form): Form
{
    return $form->schema([
        // ... other fields
        ArCaptcha::make('captcha')
            ->

use Ghorbani\FilamentArCaptchaField\Forms\Components\ArCaptcha;

public $captcha = ''; // must be initialized

protected function getFormSchema(): array
{
    return [
        // ... other fields
        ArCaptcha::make('captcha')
            ->

ArCaptcha::make('captcha')
    ->options([
        'lang' => 'en',
        'theme' => 'dark',
    ])

ArCaptcha::make('captcha')
    ->siteKey('your-custom-site-key')
    ->secretKey('your-custom-secret-key')

use Ghorbani\FilamentArCaptchaField\Rules\ArCaptchaRule;

// In your form rules
protected function getFormValidationRules(): array
{
    return [
        'captcha' => ['

use Ghorbani\FilamentArCaptchaField\Rules\ArCaptchaRule;

public function submit()
{
    $this->validate([
        'captcha' => ['

use Ghorbani\FilamentArCaptchaField\Forms\Components\ArCaptcha;

$arcaptcha = ArCaptcha::make('captcha');

if ($arcaptcha->verify($data['captcha'])) {
    // Captcha is valid
} else {
    // Captcha is invalid
    throw new \Exception('Invalid captcha');
}

use Ghorbani\FilamentArCaptchaField\Forms\Components\ArCaptcha;

public function submit()
{
    $this->validate();
    
    $arcaptcha = ArCaptcha::make('captcha');
    
    if (!$arcaptcha->verify($this->captcha)) {
        $this->addError('captcha', 'Invalid captcha. Please try again.');
        return;
    }
    
    // Process form submission
}

return [
    'site_key' => env('ARCAPTCHA_SITE_KEY', ''),
    'secret_key' => env('ARCAPTCHA_SECRET_KEY', ''),
    'options' => [
        'lang' => 'fa', // Language: 'fa' or 'en'
        'theme' => 'light', // Theme: 'light' or 'dark'
    ],
];
bash
php artisan vendor:publish --provider="Ghorbani\FilamentArCaptchaField\FilamentArCaptchaFieldServiceProvider" --tag="config"