PHP code example of yepsua / filament-captcha-field

1. Go to this page and download the library: Download yepsua/filament-captcha-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/ */

    

yepsua / filament-captcha-field example snippets


    use Yepsua\Filament\Forms\Components\Captcha;
    ...
    protected function getFormSchema(): array
    {
        return [
            Forms\Components\TextInput::make('username'),
            Forms\Components\TextInput::make('password')->type('password'),
            Captcha::make('captcha')
        ];
    }


    use Yepsua\Filament\Forms\Components\CaptchaImage;
    ...
    protected function getFormSchema(): array
    {
        return [
            Forms\Components\TextInput::make('username'),
            Forms\Components\TextInput::make('password')->type('password'),
            Forms\Components\TextInput::make('captcha')->

    use Yepsua\Filament\Forms\Components\Captcha;
    ...
    protected function getFormSchema(): array
    {
        return [
            Captcha::make('captcha')->config('math')
        ];
    }

return [
    ...
    'captcha'             => 'Invalid captcha.',
    ...
]




namespace  App\Filament\Pages\Auth;

use Filament\Http\Livewire\Auth\Login as BaseLoginPage;
use Yepsua\Filament\Forms\Components\Captcha;

class Login extends BaseLoginPage
{

    protected function getFormSchema(): array
    {
        $formSchema = parent::getFormSchema();
        $formSchema[] = Captcha::make('captcha');

        return $formSchema;
    }
}
 

return [
    ...
    'auth' => [
        'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
        'pages' => [
            // 'login' => \Filament\Http\Livewire\Auth\Login::class, // <- Original form
            'login' => \App\Filament\Pages\Auth\Login::class,        // <- Form with captcha
        ],
    ],
    ...
]
bash
php artisan vendor:publish --provider="Mews\Captcha\CaptchaServiceProvider" --tag="config"