|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Mews\Captcha; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class CaptchaServiceProvider |
|
9
|
|
|
* @package Mews\Captcha |
|
10
|
|
|
*/ |
|
11
|
|
|
class CaptchaServiceProvider extends ServiceProvider { |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Boot the service provider. |
|
15
|
|
|
* |
|
16
|
|
|
* @return null |
|
17
|
|
|
*/ |
|
18
|
|
|
public function boot() |
|
19
|
|
|
{ |
|
20
|
|
|
// Publish configuration files |
|
21
|
|
|
$this->publishes([ |
|
22
|
|
|
__DIR__.'/../config/captcha.php' => config_path('captcha.php') |
|
23
|
|
|
], 'config'); |
|
24
|
|
|
|
|
25
|
|
|
// HTTP routing |
|
26
|
|
|
if (strpos($this->app->version(), 'Lumen') !== false) { |
|
27
|
|
|
//Laravel Lumen |
|
28
|
|
|
$this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha'); |
|
|
|
|
|
|
29
|
|
|
} else if (starts_with($this->app->version(), '5.2.') !== false) { |
|
30
|
|
|
//Laravel 5.2.x |
|
31
|
|
|
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web'); |
|
32
|
|
|
} else { |
|
33
|
|
|
//Laravel 5.0.x ~ 5.1.x |
|
34
|
|
|
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// Validator extensions |
|
38
|
|
|
$this->app['validator']->extend('captcha', function($attribute, $value, $parameters) |
|
|
|
|
|
|
39
|
|
|
{ |
|
40
|
|
|
return captcha_check($value); |
|
41
|
|
|
}); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Register the service provider. |
|
46
|
|
|
* |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public function register() |
|
50
|
|
|
{ |
|
51
|
|
|
// Merge configs |
|
52
|
|
|
$this->mergeConfigFrom( |
|
53
|
|
|
__DIR__.'/../config/captcha.php', 'captcha' |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
// Bind captcha |
|
57
|
|
|
$this->app->bind('captcha', function($app) |
|
58
|
|
|
{ |
|
59
|
|
|
return new Captcha( |
|
60
|
|
|
$app['Illuminate\Filesystem\Filesystem'], |
|
61
|
|
|
$app['Illuminate\Config\Repository'], |
|
62
|
|
|
$app['Intervention\Image\ImageManager'], |
|
63
|
|
|
$app['Illuminate\Session\Store'], |
|
64
|
|
|
$app['Illuminate\Hashing\BcryptHasher'], |
|
65
|
|
|
$app['Illuminate\Support\Str'] |
|
66
|
|
|
); |
|
67
|
|
|
}); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.