1 | <?php |
||
16 | class InventoryServiceProvider extends ServiceProvider |
||
17 | { |
||
18 | /** |
||
19 | * Register package services. |
||
20 | */ |
||
21 | public function register() |
||
22 | { |
||
23 | include __DIR__.'/routes.php'; |
||
24 | $this->app->make('Scool\Inventory\InventoryController'); |
||
25 | if (!defined('SCOOL_INVENTORY_PATH')) { |
||
26 | define('SCOOL_INVENTORY_PATH', realpath(__DIR__.'/../../')); |
||
27 | } |
||
28 | $this->registerNamesServiceProvider(); |
||
29 | $this->registerStatefulEloquentServiceProvider(); |
||
30 | $this->bindRepositories(); |
||
31 | $this->app->bind(StatsRepositoryInterface::class, function () { |
||
32 | return new CacheableStatsRepository(new StatsRepository()); |
||
33 | }); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Bind repositories. |
||
38 | */ |
||
39 | protected function bindRepositories() |
||
48 | |||
49 | /** |
||
50 | * Register acacha/stateful-eloquent Service Provider. |
||
51 | */ |
||
52 | protected function registerStatefulEloquentServiceProvider() |
||
53 | { |
||
54 | $this->app->register(StatefulServiceProvider::class); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Register acacha/names Service Provider. |
||
59 | */ |
||
60 | protected function registerNamesServiceProvider() |
||
61 | { |
||
62 | $this->app->register(NamesServiceProvider::class); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Bootstrap package services. |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | public function boot() |
||
79 | |||
80 | /** |
||
81 | * Define the curriculum routes. |
||
82 | */ |
||
83 | protected function defineRoutes() |
||
84 | { |
||
85 | if (!$this->app->routesAreCached()) { |
||
86 | $router = app('router'); |
||
87 | $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () { |
||
88 | require __DIR__.'/../Http/routes.php'; |
||
89 | }); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Load package views. |
||
95 | */ |
||
96 | private function loadViews() |
||
97 | { |
||
98 | $this->loadViewsFrom(SCOOL_INVENTORY_PATH.'/resources/views', 'inventory'); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Load migrations. |
||
103 | */ |
||
104 | private function loadMigrations() |
||
105 | { |
||
106 | $this->loadMigrationsFrom(SCOOL_INVENTORY_PATH.'/database/migrations'); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Publish factories. |
||
111 | */ |
||
112 | private function publishFactories() |
||
113 | { |
||
114 | $this->publishes( |
||
115 | ScoolInventory::factories(), 'scool_inventory' |
||
116 | ); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Publish config. |
||
121 | */ |
||
122 | private function publishConfig() |
||
123 | { |
||
124 | $this->publishes( |
||
125 | ScoolInventory::configs(), 'scool_inventory' |
||
126 | ); |
||
127 | $this->mergeConfigFrom( |
||
128 | SCOOL_INVENTORY_PATH.'/config/inventory.php', 'scool_inventory' |
||
129 | ); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Publich tests. |
||
134 | */ |
||
135 | private function publishTests() |
||
142 | } |
||
143 |