| 1 | <?php |
||
| 9 | class FreshdeskServiceProvider extends ServiceProvider |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Bootstrap the application services. |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public function boot() |
||
| 17 | { |
||
| 18 | $source = dirname(__DIR__).'/src/config/freshdesk.php'; |
||
| 19 | |||
| 20 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
||
| 21 | $this->publishes([$source => config_path('freshdesk.php')]); |
||
| 22 | } elseif ($this->app instanceof LumenApplication) { |
||
| 23 | $this->app->configure('freshdesk'); |
||
| 24 | } |
||
| 25 | $this->mergeConfigFrom($source, 'freshdesk'); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Register the application services. |
||
| 30 | * |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function register() |
||
| 34 | { |
||
| 35 | $this->app->singleton('freshdesk', function ($app) { |
||
| 36 | $config = $app->make('config')->get('freshdesk'); |
||
| 37 | return new Api($config['api_key'], $config['domain']); |
||
| 38 | }); |
||
| 39 | $this->app->alias('freshdesk', Api::class); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the services provided by the provider. |
||
| 44 | * |
||
| 45 | * @return array |
||
| 46 | */ |
||
| 47 | public function provides() |
||
| 51 | } |
||
| 52 |