RouteServiceProvider.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * The path to the "home" route for your application.
  17. *
  18. * @var string
  19. */
  20. public const HOME = '/home';
  21. /**
  22. * Define your route model bindings, pattern filters, etc.
  23. *
  24. * @return void
  25. */
  26. public function boot()
  27. {
  28. //
  29. parent::boot();
  30. }
  31. /**
  32. * Define the routes for the application.
  33. *
  34. * @return void
  35. */
  36. public function map()
  37. {
  38. $this->mapApiRoutes();
  39. $this->mapWebRoutes();
  40. $this->mapWxRoutes();
  41. $this->mapDeviceRoutes();
  42. //
  43. }
  44. /**
  45. * Define the "web" routes for the application.
  46. *
  47. * These routes all receive session state, CSRF protection, etc.
  48. *
  49. * @return void
  50. */
  51. protected function mapWebRoutes()
  52. {
  53. Route::middleware('web')
  54. ->namespace($this->namespace)
  55. ->group(base_path('routes/web.php'));
  56. }
  57. /**
  58. * Define the "api" routes for the application.
  59. *
  60. * These routes are typically stateless.
  61. *
  62. * @return void
  63. */
  64. protected function mapApiRoutes()
  65. {
  66. Route::prefix('api')
  67. ->middleware('api')
  68. ->namespace($this->namespace)
  69. ->group(base_path('routes/api.php'));
  70. }
  71. protected function mapWxRoutes()
  72. {
  73. Route::prefix('weixin')
  74. ->middleware('api')
  75. ->namespace($this->namespace)
  76. ->group(base_path('routes/weixin.php'));
  77. }
  78. protected function mapDeviceRoutes()
  79. {
  80. Route::middleware('api')
  81. ->namespace($this->namespace)
  82. ->group(base_path('routes/device.php'));
  83. }
  84. }