Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ousid committed May 27, 2023
1 parent 77985aa commit da41e1e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<form action="" method="post">
@csrf
<div>
<input type="text" name="name" />
@error('name')
<p class="error">{{ $message }}</p>
@enderror
</div>
<div>
<x-turnstile-widget theme="auto" language="fr"/>
@error('cf-turnstile-response')
<p class="error">{{ $message }}</p>
@enderror
</div>
<button>Submit</button>
</form>
```

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
Expand Down

0 comments on commit da41e1e

Please sign in to comment.