1 | <?php namespace Propaganistas\LaravelPhone; |
||
11 | class PhoneServiceProvider extends ServiceProvider |
||
12 | { |
||
13 | /** |
||
14 | * Bootstrap the application events. |
||
15 | * |
||
16 | * @return void |
||
17 | */ |
||
18 | 159 | public function boot() |
|
24 | |||
25 | /** |
||
26 | * Register the service provider. |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | 159 | public function register() |
|
31 | { |
||
32 | $this->app->singleton('libphonenumber', function ($app) { |
||
33 | return PhoneNumberUtil::getInstance(); |
||
34 | 159 | }); |
|
35 | |||
36 | 159 | $this->app->alias('libphonenumber', PhoneNumberUtil::class); |
|
37 | 159 | } |
|
38 | |||
39 | /** |
||
40 | * Register the "phone" validator. |
||
41 | */ |
||
42 | 159 | protected function registerValidator() |
|
48 | |||
49 | /** |
||
50 | * Register the "phone" rule macro. |
||
51 | */ |
||
52 | 159 | protected function registerRule() |
|
53 | { |
||
54 | 159 | if (class_exists('Illuminate\Validation\Rule') && class_uses(Rule::class, Macroable::class)) { |
|
55 | Rule::macro('phone', function () { |
||
56 | return new Rules\Phone; |
||
57 | 159 | }); |
|
58 | } |
||
59 | 159 | } |
|
60 | |||
61 | /** |
||
62 | * Determine whether we can register a dependent validator. |
||
63 | * |
||
64 | * @return bool |
||
65 | */ |
||
66 | 159 | public static function canUseDependentValidation() |
|
72 | } |
||
73 |