Initial Commit
This commit is contained in:
25
app/Traits/CaptchaTrait.php
Normal file
25
app/Traits/CaptchaTrait.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php namespace App\Traits;
|
||||
|
||||
use Input;
|
||||
use ReCaptcha\ReCaptcha;
|
||||
|
||||
trait CaptchaTrait {
|
||||
|
||||
public function captchaCheck()
|
||||
{
|
||||
|
||||
$response = Input::get('g-recaptcha-response');
|
||||
$remoteip = $_SERVER['REMOTE_ADDR'];
|
||||
$secret = env('CAPTCHA_SECRET_KEY');
|
||||
|
||||
$recaptcha = new ReCaptcha($secret);
|
||||
$resp = $recaptcha->verify($response, $remoteip);
|
||||
if ($resp->isSuccess()) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user