Validation Message Added
This commit is contained in:
parent
8ca470f4ea
commit
320b00ac4f
|
|
@ -90,7 +90,7 @@ class Captcha implements CaptchaContract
|
|||
public function renderJS(): string
|
||||
{
|
||||
return $this->isActive()
|
||||
? '<script src="' . $this->getClientEndpoint() . '" async defer></script>'
|
||||
? $this->getCaptchaJSView()
|
||||
: '';
|
||||
}
|
||||
|
||||
|
|
@ -101,10 +101,8 @@ class Captcha implements CaptchaContract
|
|||
*/
|
||||
public function render(): string
|
||||
{
|
||||
$htmlAttributes = $this->buildHTMLAttributes($this->getAttributes());
|
||||
|
||||
return $this->isActive()
|
||||
? "<div {$htmlAttributes}></div>"
|
||||
? $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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<script src="{{ $clientEndPoint }}" async defer></script>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<div {!! $htmlAttributes !!}></div>
|
||||
|
||||
@if ($errors->has('g-recaptcha-response'))
|
||||
<span class="control-error">
|
||||
{{ $errors->first('g-recaptcha-response') }}
|
||||
</span>
|
||||
@endif
|
||||
|
|
@ -91,7 +91,11 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{!! Captcha::render() !!}
|
||||
<div class="form-group">
|
||||
|
||||
{!! Captcha::render() !!}
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.customers.login_form_controls.after') !!}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue