Created
August 22, 2016 07:04
-
-
Save ferdiunal/0766a34d351f3f37020854ea4227c5ff to your computer and use it in GitHub Desktop.
Google reCaptcha Validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
\Validator::extend('captcha', function($attribute, $value, $parameters, $validator) { | |
$secret = config('app.reCaptcha.secret') // Google Recaptcha oluşturulurken verilen kod | |
$recaptcha = new ReCaptcha($secret); | |
$remoteIP = \request()->ip(); | |
$resp = $recaptcha->verify($value, $remoteIP); | |
return $resp->isSuccess(); | |
}); | |
} | |
/** | |
* Register any application services. | |
* | |
* @return void | |
*/ | |
public function register() | |
{ | |
// | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment