| 1 |  |  | <?php namespace Arcanedev\RouteViewer\Providers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Illuminate\Contracts\Routing\Registrar as Router; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Arcanedev\RouteViewer\Http\Routes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Class     RouteServiceProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @package  Arcanedev\RouteViewer\Providers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @author   ARCANEDEV <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class RouteServiceProvider extends ServiceProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /* ------------------------------------------------------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     |  Getters & Setters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     | ------------------------------------------------------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * Get route attributes. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 90 |  |     public function routeAttributes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 90 |  |         return $this->config('attributes', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 90 |  |             'prefix'     => 'route-viewer', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 30 |  |             'as'         => 'route-viewer::', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 30 |  |             'namespace'  => 'Arcanedev\\RouteViewer\\Http\\Controllers', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 30 |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * Check if routes is enabled. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 90 |  |     public function isEnabled() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 90 |  |         return $this->config('enabled', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * Get config value by key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @param  string      $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @param  mixed|null  $default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 90 |  |     private function config($key, $default = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         /** @var  \Illuminate\Config\Repository  $config */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 90 |  |         $config = $this->app['config']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 90 |  |         return $config->get("route-viewer.route.{$key}", $default); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /* ------------------------------------------------------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      |  Main Functions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      | ------------------------------------------------------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * Define the routes for the application. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @param  \Illuminate\Contracts\Routing\Registrar  $router | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 68 | 90 |  |     public function map(Router $router) | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 70 | 90 |  |         if ($this->isEnabled()) { | 
            
                                                        
            
                                    
            
            
                | 71 | 90 |  |             $router->group($this->routeAttributes(), function(Router $router) { | 
            
                                                        
            
                                    
            
            
                | 72 | 90 |  |                 Routes\RouteViewerRoutes::register($router); | 
            
                                                        
            
                                    
            
            
                | 73 | 90 |  |             }); | 
            
                                                        
            
                                    
            
            
                | 74 | 30 |  |         } | 
            
                                                        
            
                                    
            
            
                | 75 | 90 |  |     } | 
            
                                                        
            
                                    
            
            
                | 76 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |  |