| 1 | <?php |
||
| 9 | class DataTablesServiceProvider extends ServiceProvider |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Register the service provider. |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public function register() |
||
| 17 | { |
||
| 18 | if ($this->isLumen()) { |
||
| 19 | require_once 'lumen.php'; |
||
| 20 | } |
||
| 21 | |||
| 22 | $this->setupAssets(); |
||
| 23 | |||
| 24 | $this->app->alias('datatables', DataTables::class); |
||
| 25 | $this->app->singleton('datatables', function () { |
||
| 26 | return new DataTables; |
||
| 27 | }); |
||
| 28 | |||
| 29 | $this->app->singleton('datatables.request', function () { |
||
| 30 | return new Request; |
||
| 31 | }); |
||
| 32 | |||
| 33 | $this->app->singleton('datatables.config', Config::class); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Setup package assets. |
||
| 38 | * |
||
| 39 | * @return void |
||
| 40 | */ |
||
| 41 | protected function setupAssets() |
||
| 42 | { |
||
| 43 | $this->mergeConfigFrom($config = __DIR__ . '/config/datatables.php', 'datatables'); |
||
| 44 | |||
| 45 | if ($this->app->runningInConsole()) { |
||
| 46 | $this->publishes([$config => config_path('datatables.php')], 'datatables'); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Check if app uses Lumen. |
||
| 52 | * |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | protected function isLumen() |
||
| 59 | } |
||
| 60 |