| 1 |  |  | <?php namespace App\Providers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Illuminate\Routing\Router; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | class RouteServiceProvider extends ServiceProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |      * This namespace is applied to the controller routes in your routes file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * In addition, it is set as the URL generator's root namespace. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     protected $namespace = 'App\Http\Controllers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * Define your route model bindings, pattern filters, etc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @param  \Illuminate\Routing\Router $router | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 31 |  |     public function boot(Router $router) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 31 |  |         $router->patterns([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 31 |  |             'provider' => 'twitter|google|facebook', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             'token' => '[a-zA-Z0-9-]+' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 31 |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 31 |  |         parent::boot($router); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 31 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * Define the routes for the application. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @param \Illuminate\Routing\Router $router | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 31 |  |     public function map(Router $router) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 31 |  |         $defaultLocale = config('app.locale'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 31 |  |         $namespace = $this->namespace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 31 |  |         $middleware = 'web'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         //----------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         // Non-localized, generic routes (such as those for admin panel etc). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         //----------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $router->group(compact('namespace', 'middleware'), function (Router $router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 31 |  |             $router->get('/oauth/{provider}', 'Users\AuthController@getOAuth'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 31 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         //----------------------------------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         // Register localized routes with locale-prefices (in case of default locale, no prefix is attached). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         //----------------------------------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 31 |  |         foreach (config('app.locales') as $prefix => $localeName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 31 |  |             app('translator')->setLocale($prefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             // Skip default locale for now. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 31 |  |             if ($prefix === $defaultLocale) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 31 |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             // Set localized routers. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $router->group(compact('namespace', 'middleware', 'prefix'), function (Router $router) use ($prefix) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 31 |  |                 $this->localizedRoutes($router, $prefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 31 |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 31 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         //------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         // Default locale: No prefices are necessary. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         //------------------------------------------------ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 31 |  |         app('translator')->setLocale($defaultLocale); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 31 |  |         $router->group(compact('namespace', 'middleware'), function (Router $router) use ($defaultLocale) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 31 |  |             $this->localizedRoutes($router, $defaultLocale); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 31 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 31 |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 80 | 31 |  |     protected function localizedRoutes(Router $router, $prefix) | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 82 | 31 |  |         $router->get('login/{provider?}', ['uses' => 'Users\AuthController@getLogin', 'as' => $prefix . '.login']); | 
            
                                                        
            
                                    
            
            
                | 83 | 31 |  |         $router->post('login/{provider?}', 'Users\AuthController@postLogin'); | 
            
                                                        
            
                                    
            
            
                | 84 | 31 |  |         $router->get('logout', ['uses' => 'Users\AuthController@getLogout', 'as' => $prefix . '.logout']); | 
            
                                                        
            
                                    
            
            
                | 85 | 31 |  |         $router->get('register', ['uses' => 'UsersController@create', 'as' => $prefix . '.register']); | 
            
                                                        
            
                                    
            
            
                | 86 | 31 |  |         $router->post('register', 'UsersController@store'); | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 88 | 31 |  |         $router->resource('users', 'UsersController'); | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 90 | 31 |  |         $router->get('password/email', 'Users\PasswordController@requestPasswordResetLink'); | 
            
                                                        
            
                                    
            
            
                | 91 | 31 |  |         $router->post('password/email', 'Users\PasswordController@sendPasswordResetLink'); | 
            
                                                        
            
                                    
            
            
                | 92 | 31 |  |         $router->get('password/reset/{token}', 'Users\PasswordController@showPasswordResetForm'); | 
            
                                                        
            
                                    
            
            
                | 93 | 31 |  |         $router->post('password/reset', 'Users\PasswordController@resetPassword'); | 
            
                                                        
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 95 | 31 |  |         $router->get('activation', 'Users\ActivationController@requestActivationCode'); | 
            
                                                        
            
                                    
            
            
                | 96 | 31 |  |         $router->get('activation/{token}', 'Users\ActivationController@activate'); | 
            
                                                        
            
                                    
            
            
                | 97 | 31 |  |         $router->post('activation', 'Users\ActivationController@activate'); | 
            
                                                        
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 99 | 31 |  |         $router->resource('files', 'FilesController', ['only' => ['index', 'create', 'store', 'show', 'destroy']]); | 
            
                                                        
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 101 | 31 |  |         $router->get('', 'HomeController@index'); | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 103 | 31 |  |         $router->get('admin', 'AdminController@index'); | 
            
                                                        
            
                                    
            
            
                | 104 | 31 |  |     } | 
            
                                                        
            
                                    
            
            
                | 105 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |  |