1. Go to this page and download the library: Download origami/captcha 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/ */
class Contact extends Controller
{
public function store(Request $request)
{
$this->validate($request, [
'recatpcha' => [new Origami\Captcha\Rules\Recaptcha]
]);
}
}
class Contact extends Controller
{
public function store(Request $request)
{
$this->validate($request, [
'recatpcha' => [new Origami\Captcha\Rules\Recaptcha(secret: '123')]
]);
}
}
use Origami\Captcha\ValidatesCaptcha;
class Contact extends Controller
{
use ValidatesCaptcha;
public function store(Request $request)
{
$this->validateRecaptcha($request);
// The above will throw a ValidationException when the recaptcha fails.
}
}