| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace JeroenNoten\LaravelAdminLte; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Contracts\Config\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Contracts\Container\Container; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Contracts\Events\Dispatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Contracts\View\Factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Illuminate\Support\ServiceProvider as BaseServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use JeroenNoten\LaravelAdminLte\Console\AdminLteInstallCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use JeroenNoten\LaravelAdminLte\Console\AdminLtePluginCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use JeroenNoten\LaravelAdminLte\Console\AdminLteStatusCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use JeroenNoten\LaravelAdminLte\Console\AdminLteUpdateCommand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use JeroenNoten\LaravelAdminLte\Events\BuildingMenu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use JeroenNoten\LaravelAdminLte\Http\ViewComposers\AdminLteComposer; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | class AdminLteServiceProvider extends BaseServiceProvider | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public function register() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->app->singleton(AdminLte::class, function (Container $app) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             return new AdminLte( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |                 $app['config']['adminlte.filters'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |                 $app['events'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |                 $app | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     public function boot( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         Factory $view, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         Dispatcher $events, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         Repository $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->loadViews(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->loadTranslations(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $this->loadConfig(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->registerCommands(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->registerViewComposers($view); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         static::registerMenu($events, $config); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     private function loadViews() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $resourceViewsPath = $this->packagePath('resources/views'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         if (file_exists($resourceViewsPath)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             $viewsPath = $resourceViewsPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $viewsPath = $this->packagePath('resources/views'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->loadViewsFrom($viewsPath, 'adminlte'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     private function loadTranslations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $translationsPath = $this->packagePath('resources/lang'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->loadTranslationsFrom($translationsPath, 'adminlte'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     private function loadConfig() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $configPath = $this->packagePath('config/adminlte.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $this->mergeConfigFrom($configPath, 'adminlte'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     private function packagePath($path) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         return __DIR__."/../$path"; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     private function registerCommands() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->commands(AdminLteInstallCommand::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $this->commands(AdminLteStatusCommand::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->commands(AdminLteUpdateCommand::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $this->commands(AdminLtePluginCommand::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     private function registerViewComposers(Factory $view) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $view->composer('adminlte::page', AdminLteComposer::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     public static function registerMenu(Dispatcher $events, Repository $config) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $events->listen(BuildingMenu::class, function (BuildingMenu $event) use ($config) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             $menu = $config->get('adminlte.menu'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             call_user_func_array([$event->menu, 'add'], $menu); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 100 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 101 |  |  |  |