Skip to content

Commit

Permalink
Merge pull request #3 from goedemiddag/feature/improve-documation
Browse files Browse the repository at this point in the history
📝 Improve documentation
  • Loading branch information
dvdheiden authored May 28, 2024
2 parents 659acdd + 530bf1f commit ecc9028
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,48 @@ RECAPTCHA_SECRET_KEY=YOUR_SECRET_KEY
RECAPTCHA_THRESHOLD=0.3
```

### Config

You can optionally publish the config file:

```bash
php artisan vendor:publish --provider="Goedemiddag\ReCaptcha\ReCaptchaServiceProvider" --tag="config"
php artisan vendor:publish --provider="Goedemiddag\ReCaptcha\ReCaptchaServiceProvider" --tag="recaptcha-config"
```

This is the contents of the published config file:

```php
return [
'site_key' => env('RECAPTCHA_SITE_KEY'),

'secret_key' => env('RECAPTCHA_SECRET_KEY'),

// The threshold to pass the recaptcha validation, from 0 (easiest) to 1 (hardest)
'threshold' => env('RECAPTCHA_THRESHOLD', 0.3),

// Provide IP addresses that shouldn't be validated
'skip_ips' => [
// 127.0.0.1
],
];
```

### Translations

This package offers Dutch and English translations by default. You can optionally publish the translations:

```bash
php artisan vendor:publish --provider="Goedemiddag\ReCaptcha\ReCaptchaServiceProvider" --tag="recaptcha-lang"
```

## Usage

This package aims to provide the Google ReCaptcha v3 validation in the backend of your application and offers some tools to use it in the frontend.

### Quick start

Add the `<x-recaptcha::input />` blade component to your form:

```blade
```bladehtml
<form method="POST">
@csrf
<x-recaptcha::input />
Expand All @@ -57,15 +72,15 @@ Add the `<x-recaptcha::input />` blade component to your form:

Add the `<x-recaptcha::script />` blade component to your end of your layout:

```blade
```bladehtml
<body>
...page content...
<x-recaptcha::script />
</body>
```

Bind an event listener to the form submit event:
Bind an event listener to the form submit event, please adjust this for your application:

```js
document.querySelector('form').addEventListener('submit', function (event) {
Expand All @@ -91,3 +106,9 @@ public function rules(): array
];
}
```

## Contributing

Found a bug or want to add a new feature? Great! There are also many other ways to make meaningful contributions such as reviewing outstanding pull requests and writing documentation. Even opening an issue for a bug you found is appreciated.

When you create a pull request, make sure it is tested, following the code standard (run `composer pint:fix` to take care of that for you) and please create one pull request per feature. In exchange, you will be credited as contributor.
5 changes: 2 additions & 3 deletions config/recaptcha.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php

return [

'site_key' => env('RECAPTCHA_SITE_KEY'),

'secret_key' => env('RECAPTCHA_SECRET_KEY'),

// The threshold to pass the recaptcha validation, from 0 (easiest) to 1 (hardest)
'threshold' => env('RECAPTCHA_THRESHOLD', 0.3),

// Provide IP addresses that shouldn't be validated
'skip_ips' => [
// 127.0.0.1
],

];

0 comments on commit ecc9028

Please sign in to comment.