RouteServiceProvider.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  4. use Illuminate\Support\Facades\Route;
  5. class RouteServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * This namespace is applied to your controller routes.
  9. *
  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. * Define your route model bindings, pattern filters, etc.
  17. *
  18. * @return void
  19. */
  20. public function boot()
  21. {
  22. //
  23. if (config('v2board.force_https')) {
  24. resolve(\Illuminate\Routing\UrlGenerator::class)->forceScheme('https');
  25. }
  26. parent::boot();
  27. }
  28. /**
  29. * Define the routes for the application.
  30. *
  31. * @return void
  32. */
  33. public function map()
  34. {
  35. $this->mapApiRoutes();
  36. $this->mapWebRoutes();
  37. //
  38. }
  39. /**
  40. * Define the "web" routes for the application.
  41. *
  42. * These routes all receive session state, CSRF protection, etc.
  43. *
  44. * @return void
  45. */
  46. protected function mapWebRoutes()
  47. {
  48. Route::middleware('web')
  49. ->namespace($this->namespace)
  50. ->group(base_path('routes/web.php'));
  51. }
  52. /**
  53. * Define the "api" routes for the application.
  54. *
  55. * These routes are typically stateless.
  56. *
  57. * @return void
  58. */
  59. protected function mapApiRoutes()
  60. {
  61. Route::group([
  62. 'prefix' => '/api/v1',
  63. 'middleware' => 'api',
  64. 'namespace' => $this->namespace
  65. ], function ($router) {
  66. foreach (glob(app_path('Http//Routes') . '/*.php') as $file) {
  67. $this->app->make('App\\Http\\Routes\\' . basename($file, '.php'))->map($router);
  68. }
  69. });
  70. }
  71. }