| 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 |  |  |      * In addition, it is set as the URL generator's root namespace. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     protected $namespace = 'App\Http\Controllers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * Define your route model bindings, pattern filters, etc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 | 19 |  |     public function boot() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 19 |  |         app('router')->patterns([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 19 |  |             'provider' => 'twitter|google|facebook', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             'token' => '[a-zA-Z0-9-]+' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 19 |  |         parent::boot(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 19 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * Define the routes for the application. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 19 |  |     public function map() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 19 |  |         $this->mapApiRoutes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 19 |  |         $this->mapWebRoutes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 19 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * Define the "api" routes for the application. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * These routes are typically stateless. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 19 |  |     protected function mapApiRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 19 |  |         app('router')->group([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 19 |  |             'middleware' => 'api', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 19 |  |             'namespace' => $this->namespace, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 19 |  |             'prefix' => 'api/v1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ], function (Router $router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 19 |  |             $router->post('login', 'Auth\LoginController@login'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 19 |  |             $router->post('logout', 'Auth\LoginController@logout')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 19 |  |             $router->post('register', 'Auth\RegisterController@register'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 19 |  |             $router->post('password/email', 'Auth\PasswordController@sendPasswordResetLink'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 19 |  |             $router->post('password/reset', 'Auth\PasswordController@resetPassword'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 19 |  |             $router->get('activation', 'Auth\ActivateController@requestActivationCode')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 19 |  |             $router->get('activation/{token}', 'Auth\ActivateController@activate')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 19 |  |             $router->post('activation', 'Auth\ActivateController@activate')->middleware('auth:api'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 19 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 19 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      * Define the "web" routes for the application. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * These routes all receive session state, CSRF protection, etc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 19 |  |     protected function mapWebRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 19 |  |         app('router')->group([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 19 |  |             'middleware' => 'web', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 19 |  |             'namespace' => $this->namespace, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         ], function (Router $router) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             //----------------------------------------------------------------------- | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 |  |  |             // Non-localized, generic routes (such as those for admin panel etc). | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |             //----------------------------------------------------------------------- | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 | 19 |  |             $router->get('oauth/to/{provider}', ['uses' => 'Auth\LoginController@handleOAuthRedirect', 'as' => 'oauth.to']); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 | 19 |  |             $router->get('oauth/from/{provider}', ['uses' => 'Auth\LoginController@handleOAuthReturn', 'as' => 'oauth.from']); | 
            
                                                                        
                            
            
                                    
            
            
                | 84 | 19 |  |             $router->get('admin', 'AdminController@index'); | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |             //----------------------------------------------------------------------------------------------------- | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |             // Register localized routes with locale-prefices (in case of default locale, no prefix is attached). | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |             //----------------------------------------------------------------------------------------------------- | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 | 19 |  |             foreach (config('app.locales') as $prefix => $localeName) { | 
            
                                                                        
                            
            
                                    
            
            
                | 91 | 19 |  |                 app('translator')->setLocale($prefix); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |                 // Localized routes. | 
            
                                                                        
                            
            
                                    
            
            
                | 93 | 19 |  |                 $router->group(compact('namespace', 'middleware', 'prefix'), function (Router $router) use ($prefix) { | 
            
                                                                        
                            
            
                                    
            
            
                | 94 | 19 |  |                     $this->localizeWebRoutes($router, $prefix); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 | 19 |  |                 }); | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |             /*------------------------------------ | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |              | Default, non-localized home | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |              *-----------------------------------*/ | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 102 | 19 |  |             $router->get('', 'HomeController@index'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 19 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 19 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @param \Illuminate\Routing\Router $router | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @param string                     $prefix | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 19 |  |     protected function localizeWebRoutes(Router $router, $prefix = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 19 |  |         $router->get('login', ['uses' => 'Auth\LoginController@showLoginForm', 'as' => empty($prefix) ?: $prefix . '.login']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 19 |  |         $router->post('login', 'Auth\LoginController@loginViaWeb'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 19 |  |         $router->get('logout', ['uses' => 'Auth\LoginController@logout', 'as' => empty($prefix) ?: $prefix . '.logout']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 19 |  |         $router->get('register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => empty($prefix) ?: $prefix . '.register']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 19 |  |         $router->post('register', 'Auth\RegisterController@register'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 19 |  |         $router->get('password/email', ['uses' => 'Auth\PasswordController@requestPasswordResetLink', 'as' => empty($prefix) ?: $prefix . '.password.email']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 19 |  |         $router->post('password/email', 'Auth\PasswordController@sendPasswordResetLink'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 19 |  |         $router->get('password/reset/{token}', ['uses' => 'Auth\PasswordController@showPasswordResetForm', 'as' => empty($prefix) ?: $prefix . '.password.reset']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 19 |  |         $router->post('password/reset', 'Auth\PasswordController@resetPassword'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 19 |  |         $router->get('activation', ['uses' => 'Auth\ActivateController@requestActivationCode', 'as' => empty($prefix) ?: $prefix . '.activation.request']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 19 |  |         $router->get('activation/{token}', ['uses' => 'Auth\ActivateController@activate', 'as' => empty($prefix) ?: $prefix . '.activation.complete']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 19 |  |         $router->post('activation', 'Auth\ActivateController@activate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 19 |  |         $router->resource('files', 'FilesController', ['only' => ['index', 'create', 'store', 'show', 'destroy']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 19 |  |         $router->get('', ['uses' => 'HomeController@index', 'as' => empty($prefix) ?: $prefix . '.home']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 19 |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 131 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 132 |  |  |  |