@@ -19,88 +19,88 @@ |
||
19 | 19 | */ |
20 | 20 | class ReCaptchaServiceProvider extends ServiceProvider { |
21 | 21 | |
22 | - /** |
|
23 | - * Indicates if loading of the provider is deferred. |
|
24 | - * |
|
25 | - * @var bool |
|
26 | - */ |
|
27 | - protected $defer = false; |
|
28 | - |
|
29 | - /** |
|
30 | - * |
|
31 | - */ |
|
32 | - public function boot() { |
|
33 | - |
|
34 | - $this->addValidationRule(); |
|
35 | - $this->loadRoutesFrom(__DIR__ . '/routes/routes.php'); |
|
36 | - |
|
37 | - $this->publishes([ |
|
38 | - __DIR__ . '/../config/recaptcha.php' => config_path('recaptcha.php'), |
|
39 | - ]); |
|
40 | - |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Extends Validator to include a recaptcha type |
|
45 | - */ |
|
46 | - public function addValidationRule() { |
|
47 | - |
|
48 | - Validator::extendImplicit('recaptcha', function ($attribute, $value, $parameters, $validator) { |
|
49 | - |
|
50 | - return app('recaptcha')->validate($value); |
|
51 | - }, trans('validation.recaptcha')); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Register the service provider. |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function register() { |
|
60 | - |
|
61 | - $this->mergeConfigFrom( |
|
62 | - __DIR__ . '/../config/recaptcha.php', 'recaptcha' |
|
63 | - ); |
|
64 | - |
|
65 | - $this->registerReCaptchaBuilder(); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Register the HTML builder instance. |
|
70 | - * |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - protected function registerReCaptchaBuilder() { |
|
74 | - |
|
75 | - $this->app->singleton('recaptcha', function ($app) { |
|
76 | - |
|
77 | - $recaptcha_class = ''; |
|
78 | - |
|
79 | - switch (config('recaptcha.version')) { |
|
80 | - case 'v3' : |
|
81 | - $recaptcha_class = ReCaptchaBuilderV3::class; |
|
82 | - break; |
|
83 | - case 'v2' : |
|
84 | - $recaptcha_class = ReCaptchaBuilderV2::class; |
|
85 | - break; |
|
86 | - case 'invisible': |
|
87 | - $recaptcha_class = ReCaptchaBuilderInvisible::class; |
|
88 | - break; |
|
89 | - } |
|
90 | - |
|
91 | - return new $recaptcha_class(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key')); |
|
92 | - |
|
93 | - }); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get the services provided by the provider. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function provides() { |
|
102 | - |
|
103 | - return ['recaptcha']; |
|
104 | - } |
|
22 | + /** |
|
23 | + * Indicates if loading of the provider is deferred. |
|
24 | + * |
|
25 | + * @var bool |
|
26 | + */ |
|
27 | + protected $defer = false; |
|
28 | + |
|
29 | + /** |
|
30 | + * |
|
31 | + */ |
|
32 | + public function boot() { |
|
33 | + |
|
34 | + $this->addValidationRule(); |
|
35 | + $this->loadRoutesFrom(__DIR__ . '/routes/routes.php'); |
|
36 | + |
|
37 | + $this->publishes([ |
|
38 | + __DIR__ . '/../config/recaptcha.php' => config_path('recaptcha.php'), |
|
39 | + ]); |
|
40 | + |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Extends Validator to include a recaptcha type |
|
45 | + */ |
|
46 | + public function addValidationRule() { |
|
47 | + |
|
48 | + Validator::extendImplicit('recaptcha', function ($attribute, $value, $parameters, $validator) { |
|
49 | + |
|
50 | + return app('recaptcha')->validate($value); |
|
51 | + }, trans('validation.recaptcha')); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Register the service provider. |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function register() { |
|
60 | + |
|
61 | + $this->mergeConfigFrom( |
|
62 | + __DIR__ . '/../config/recaptcha.php', 'recaptcha' |
|
63 | + ); |
|
64 | + |
|
65 | + $this->registerReCaptchaBuilder(); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Register the HTML builder instance. |
|
70 | + * |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + protected function registerReCaptchaBuilder() { |
|
74 | + |
|
75 | + $this->app->singleton('recaptcha', function ($app) { |
|
76 | + |
|
77 | + $recaptcha_class = ''; |
|
78 | + |
|
79 | + switch (config('recaptcha.version')) { |
|
80 | + case 'v3' : |
|
81 | + $recaptcha_class = ReCaptchaBuilderV3::class; |
|
82 | + break; |
|
83 | + case 'v2' : |
|
84 | + $recaptcha_class = ReCaptchaBuilderV2::class; |
|
85 | + break; |
|
86 | + case 'invisible': |
|
87 | + $recaptcha_class = ReCaptchaBuilderInvisible::class; |
|
88 | + break; |
|
89 | + } |
|
90 | + |
|
91 | + return new $recaptcha_class(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key')); |
|
92 | + |
|
93 | + }); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get the services provided by the provider. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function provides() { |
|
102 | + |
|
103 | + return ['recaptcha']; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | } |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | public function boot() { |
33 | 33 | |
34 | 34 | $this->addValidationRule(); |
35 | - $this->loadRoutesFrom(__DIR__ . '/routes/routes.php'); |
|
35 | + $this->loadRoutesFrom(__DIR__.'/routes/routes.php'); |
|
36 | 36 | |
37 | 37 | $this->publishes([ |
38 | - __DIR__ . '/../config/recaptcha.php' => config_path('recaptcha.php'), |
|
38 | + __DIR__.'/../config/recaptcha.php' => config_path('recaptcha.php'), |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function addValidationRule() { |
47 | 47 | |
48 | - Validator::extendImplicit('recaptcha', function ($attribute, $value, $parameters, $validator) { |
|
48 | + Validator::extendImplicit('recaptcha', function($attribute, $value, $parameters, $validator) { |
|
49 | 49 | |
50 | 50 | return app('recaptcha')->validate($value); |
51 | 51 | }, trans('validation.recaptcha')); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function register() { |
60 | 60 | |
61 | 61 | $this->mergeConfigFrom( |
62 | - __DIR__ . '/../config/recaptcha.php', 'recaptcha' |
|
62 | + __DIR__.'/../config/recaptcha.php', 'recaptcha' |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | $this->registerReCaptchaBuilder(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function registerReCaptchaBuilder() { |
74 | 74 | |
75 | - $this->app->singleton('recaptcha', function ($app) { |
|
75 | + $this->app->singleton('recaptcha', function($app) { |
|
76 | 76 | |
77 | 77 | $recaptcha_class = ''; |
78 | 78 |
@@ -9,6 +9,6 @@ |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | Route::get( |
12 | - config('recaptcha.default_validation_route', 'biscolab-recaptcha/validate'), |
|
13 | - ['uses' => 'Biscolab\ReCaptcha\Controllers\ReCaptchaController@validateV3'] |
|
12 | + config('recaptcha.default_validation_route', 'biscolab-recaptcha/validate'), |
|
13 | + ['uses' => 'Biscolab\ReCaptcha\Controllers\ReCaptchaController@validateV3'] |
|
14 | 14 | )->middleware('web'); |
15 | 15 | \ No newline at end of file |
@@ -18,12 +18,12 @@ |
||
18 | 18 | */ |
19 | 19 | class ReCaptchaController extends Controller { |
20 | 20 | |
21 | - /** |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function validateV3(): array { |
|
21 | + /** |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function validateV3(): array { |
|
25 | 25 | |
26 | - $token = request()->input(config('recaptcha.default_token_parameter_name', 'token'), ''); |
|
27 | - return recaptcha()->validate($token); |
|
28 | - } |
|
26 | + $token = request()->input(config('recaptcha.default_token_parameter_name', 'token'), ''); |
|
27 | + return recaptcha()->validate($token); |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |