| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace Triadev\Leopard\Provider; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Illuminate\Foundation\AliasLoader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Support\ServiceProvider as BaseServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Triadev\Leopard\Business\Repository\ElasticsearchRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Triadev\Leopard\Business\Repository\MappingLogRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Triadev\Leopard\Console\Commands\Index\Sync; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Triadev\Leopard\Console\Commands\Mapping\Make; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Triadev\Leopard\Console\Commands\Mapping\Migrate; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Triadev\Leopard\Console\Commands\Mapping\Rollback; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Triadev\Leopard\Contract\ElasticsearchManagerContract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Triadev\Leopard\Contract\Repository\ElasticsearchRepositoryContract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Triadev\Leopard\Contract\Repository\MappingLogRepositoryContract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Triadev\Leopard\ElasticsearchManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Triadev\Leopard\Facade\Leopard; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Triadev\Es\Provider\ElasticsearchServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | class ServiceProvider extends BaseServiceProvider | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * All of the container bindings that should be registered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     public $bindings = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         ElasticsearchRepositoryContract::class => ElasticsearchRepository::class, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         MappingLogRepositoryContract::class => MappingLogRepository::class | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     ]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * All of the container singletons that should be registered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public $singletons = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         ElasticsearchManagerContract::class => ElasticsearchManager::class, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     ]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * Bootstrap the application events. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 45 | 132 |  |     public function boot() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 47 | 132 |  |         $source = realpath(__DIR__ . '/../Config/config.php'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 49 | 132 |  |         $this->publishes([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 50 | 132 |  |             __DIR__ . '/../Config/config.php' => config_path('leopard.php'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 51 | 132 |  |         ], 'config'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 53 | 132 |  |         $this->mergeConfigFrom($source, 'leopard'); | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 55 | 132 |  |         $this->loadMigrationsFrom(__DIR__ . '/../Resources/database/migrations'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 57 | 132 |  |         $this->publishes([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 58 | 132 |  |             __DIR__.'/Resources/database' => database_path(), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 59 | 132 |  |         ], 'database'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 61 | 132 |  |         $this->commands([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 62 | 132 |  |             Make::class, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |             Migrate::class, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |             Rollback::class, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |             Sync::class | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         ]); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 132 |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * Register bindings in the container. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 132 |  |     public function register() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 132 |  |         $this->app->register(ElasticsearchServiceProvider::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 132 |  |         AliasLoader::getInstance()->alias('Leopard', Leopard::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 132 |  |     } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 80 |  |  | } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |  |