| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace TypeHints\Unused; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Filesystem\Filesystem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Support\ServiceProvider as BaseServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class ServiceProvider extends BaseServiceProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     public function register() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |         $configPath = __DIR__.'/../config/laravelunused.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         $this->mergeConfigFrom($configPath, 'laravelunused'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public function boot() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravelunused'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->publishRoutes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $this->publishAssets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->publishConfig(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public function publishRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $routeConfig = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             'namespace'  => 'TypeHints\Unused\Controllers', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             'prefix'     => $this->app['config']->get('laravelunused.route_prefix'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             'middleware' => $this->app['config']->get('laravelunused.middleware'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->app['router']->group($routeConfig, function ($router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             $router->get('/{view?}', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 'uses' => 'LaravelUnusedController', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                 'as'   => 'laravelunused.dashboard', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             ])->where('view', '(.*)'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             $router->delete('/delete/{view}', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                 'uses' => 'LaravelUnusedController@delete', | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 'as'   => 'laravelunused.delete', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     protected function publishAssets(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         // if (file_exists(public_path('vendor/laravelunused'))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         //     return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         // } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         // (new Filesystem)->link( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         //     __DIR__.'/../public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         //     public_path('vendor/laravelunused') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         // ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->publishes([__DIR__.'/../public' => public_path('vendor/laravelunused')], 'laravelunused-assets'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     protected function publishConfig(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         $this->publishes([__DIR__.'/../config/laravelunused.php' => config_path('laravelunused.php')], 'config'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  | 
            
                        
If there is a route defined but the controller class cannot be found there are two options: 1. the controller class needs to be implemented or 2. the route is outdated and can be removed.
If ?FooController? was found and ?BarController? is missing for the following example, either the controller should be implemented or the route should be removed: