php - Validator extend implicit not firing in AppServiceProvider -


i trying verify recaptcha response on form posting url google provide, when try fire via appserviceprovider not hitting @ , skipping it. can see validator working formrequest reason not firing check function on captchavalidator

here appserviceprovider

<?php  namespace app\providers;  use illuminate\support\serviceprovider;  class appserviceprovider extends serviceprovider {     /**      * bootstrap application services.      *      * @return void      */     public function boot()     {         \schema::defaultstringlength(191);          if ($this->app->environment() == 'production') {             \url::forcescheme('https');         }          \validator::extendimplicit('recaptcha', 'app\validation\captchavalidator@check',             'you have not passed recaptcha.');     }      /**      * register application services.      *      * @return void      */     public function register()     {         if ($this->app->environment() !== 'production') {             $this->app->register(\barryvdh\laravelidehelper\idehelperserviceprovider::class);         }     } } 

captchavalidator

<?php  namespace app\validation;  use guzzlehttp\client;  class captchavalidator {     public function check($attribute, $value, $parameters)     {         $parameters = http_build_query([             'secret' => env('recaptcha_private_key'),             'remoteip' => app('request')->getclientip(),             'response' => $value,         ]);          $url = 'https://www.google.com/recaptcha/api/siteverify?' . $parameters;          $client = new client();         $response = $client->request('post', $url);          try {             $results = json_decode($response->getbody()->getcontents());              return $results->success;         } catch (\exception $exception) {         }          return true;     } } 

request form validation

<?php  namespace app\http\requests;  use illuminate\foundation\http\formrequest;  class redeemrequest extends formrequest {     /**      * determine if user authorized make request.      *      * @return bool      */     public function authorize()     {         return true;     }      /**      * validation rules apply request.      *      * @return array      */     public function rules()     {         return [             'g-recaptcha-response' => 'required|recaptcha',         ];     } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -