diff --git a/README.md b/README.md index 9eb5488..3a1e2a2 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,56 @@ return [ __PS__: If you want to translate the message, just copy the message and translate it, because it uses the translator method behind the scene. +## Reallife Example +In your blade file + +```blade +
+ @csrf +
+ + @error('name') +

{{ $message }}

+ @enderror +
+ +
+ + @error('cf-turnstile-response') +

{{ $message }}

+ @enderror +
+ + +
+``` + +In your controller: + +```php +use Coderflex\LaravelTurnstile\Rules\TurnstileCheck; +use Coderflex\LaravelTurnstile\Facades\LaravelTurnstile; + +... + +public function store(Request $request) +{ + $request->validate([ + 'name' => ['required', 'string', 'max:250'], + 'cf-turnstile-response' => ['required', new TurnstileCheck()], + ]); + + // or + $response = LaravelTurnstile::validate(); + + if (! $response['success']) { + // do your thing. + } + + // do your things. +} +``` + ## Testing ```bash