| 1 | <?php |
||
| 9 | class TwilioProvider extends ServiceProvider |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Bootstrap the application services. |
||
| 13 | */ |
||
| 14 | 2 | public function boot() |
|
| 15 | { |
||
| 16 | 2 | $this->app->when(TwilioChannel::class) |
|
| 17 | 2 | ->needs(Twilio::class) |
|
| 18 | ->give(function () { |
||
| 19 | 2 | return new Twilio( |
|
| 20 | 2 | $this->app->make(TwilioService::class), |
|
| 21 | 2 | $this->app->make(TwilioConfig::class) |
|
| 22 | ); |
||
| 23 | 2 | }); |
|
| 24 | |||
| 25 | $this->app->bind(TwilioService::class, function () { |
||
| 26 | 2 | $config = $this->app['config']['services.twilio']; |
|
| 27 | 2 | $account_sid = Arr::get($config, 'account_sid'); |
|
| 28 | 2 | $username = Arr::get($config, 'username'); |
|
| 29 | 2 | if (! empty($username)) { |
|
| 30 | 1 | $password = Arr::get($config, 'password'); |
|
| 31 | |||
| 32 | 1 | return new TwilioService($username, $password, $account_sid); |
|
| 33 | } else { |
||
| 34 | 1 | $auth_token = Arr::get($config, 'auth_token'); |
|
| 35 | |||
| 36 | 1 | return new TwilioService($account_sid, $auth_token); |
|
| 37 | } |
||
| 38 | 2 | }); |
|
| 39 | 2 | } |
|
| 40 | |||
| 41 | /** |
||
| 42 | * Register the application services. |
||
| 43 | */ |
||
| 44 | public function register() |
||
| 50 | } |
||
| 51 |