diff --git a/packages/Webkul/Customer/src/Captcha.php b/packages/Webkul/Customer/src/Captcha.php index a0aa84685..350c21b1c 100644 --- a/packages/Webkul/Customer/src/Captcha.php +++ b/packages/Webkul/Customer/src/Captcha.php @@ -90,7 +90,7 @@ class Captcha implements CaptchaContract public function renderJS(): string { return $this->isActive() - ? '' + ? $this->getCaptchaJSView() : ''; } @@ -101,10 +101,8 @@ class Captcha implements CaptchaContract */ public function render(): string { - $htmlAttributes = $this->buildHTMLAttributes($this->getAttributes()); - return $this->isActive() - ? "
" + ? $this->getCaptchaView() : ''; } @@ -158,4 +156,30 @@ class Captcha implements CaptchaContract ? implode(' ', $htmlAttributes) : ''; } + + /** + * Get captcha view. + * + * @return string + */ + protected function getCaptchaView() + { + $htmlAttributes = $this->buildHTMLAttributes($this->getAttributes()); + + return view('customer::captcha.view', [ + 'htmlAttributes' => $htmlAttributes + ])->render(); + } + + /** + * Get captcha script view. + * + * @return string + */ + protected function getCaptchaJSView() + { + return view('customer::captcha.scripts', [ + 'clientEndPoint' => $this->getClientEndpoint() + ])->render(); + } } diff --git a/packages/Webkul/Customer/src/Http/Requests/CustomerLoginRequest.php b/packages/Webkul/Customer/src/Http/Requests/CustomerLoginRequest.php index 9a79295c1..9a48cc574 100644 --- a/packages/Webkul/Customer/src/Http/Requests/CustomerLoginRequest.php +++ b/packages/Webkul/Customer/src/Http/Requests/CustomerLoginRequest.php @@ -38,4 +38,16 @@ class CustomerLoginRequest extends FormRequest ? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha']) : $this->rules; } + + /** + * Get custom messages for validator errors. + * + * @return array + */ + public function messages() + { + return [ + 'g-recaptcha-response.required' => 'Please select CAPTCHA' + ]; + } } diff --git a/packages/Webkul/Customer/src/Http/Requests/CustomerRegistrationRequest.php b/packages/Webkul/Customer/src/Http/Requests/CustomerRegistrationRequest.php index 4a7369901..35074c9c7 100644 --- a/packages/Webkul/Customer/src/Http/Requests/CustomerRegistrationRequest.php +++ b/packages/Webkul/Customer/src/Http/Requests/CustomerRegistrationRequest.php @@ -40,4 +40,16 @@ class CustomerRegistrationRequest extends FormRequest ? array_merge($this->rules, ['g-recaptcha-response' => 'required|captcha']) : $this->rules; } + + /** + * Get custom messages for validator errors. + * + * @return array + */ + public function messages() + { + return [ + 'g-recaptcha-response.required' => 'Please select CAPTCHA' + ]; + } } diff --git a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php index 8b7f1fd02..a482df188 100755 --- a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php +++ b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php @@ -19,9 +19,11 @@ class CustomerServiceProvider extends ServiceProvider { $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer'); - $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customer'); $this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) { return $this->app['captcha']->validateResponse($value); diff --git a/packages/Webkul/Customer/src/Resources/views/captcha/scripts.blade.php b/packages/Webkul/Customer/src/Resources/views/captcha/scripts.blade.php new file mode 100644 index 000000000..e8f54e6ff --- /dev/null +++ b/packages/Webkul/Customer/src/Resources/views/captcha/scripts.blade.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Resources/views/captcha/view.blade.php b/packages/Webkul/Customer/src/Resources/views/captcha/view.blade.php new file mode 100644 index 000000000..be3d72df2 --- /dev/null +++ b/packages/Webkul/Customer/src/Resources/views/captcha/view.blade.php @@ -0,0 +1,7 @@ + + +@if ($errors->has('g-recaptcha-response')) + + {{ $errors->first('g-recaptcha-response') }} + +@endif \ No newline at end of file diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/customers/session/index.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/customers/session/index.blade.php index e992da641..4c15d8ee7 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/customers/session/index.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/customers/session/index.blade.php @@ -91,7 +91,11 @@ - {!! Captcha::render() !!} +