RouteServiceProvider.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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->mapWeixinRoutes();
  41. $this->mapAssetApiRoutes();
  42. $this->mapMaycurRoutes();
  43. //
  44. }
  45. /**
  46. * Define the "web" routes for the application.
  47. *
  48. * These routes all receive session state, CSRF protection, etc.
  49. *
  50. * @return void
  51. */
  52. protected function mapWebRoutes()
  53. {
  54. Route::middleware('web')
  55. ->namespace($this->namespace)
  56. ->group(base_path('routes/web.php'));
  57. }
  58. /**
  59. * Define the "api" routes for the application.
  60. *
  61. * These routes are typically stateless.
  62. *
  63. * @return void
  64. */
  65. protected function mapApiRoutes()
  66. {
  67. Route::prefix('api')
  68. ->middleware('api')
  69. ->namespace($this->namespace)
  70. ->group(base_path('routes/api.php'));
  71. }
  72. protected function mapAssetApiRoutes()
  73. {
  74. Route::prefix('assetapi')
  75. ->middleware('api')
  76. ->namespace($this->namespace)
  77. ->group(base_path('routes/asset.php'));
  78. }
  79. protected function mapWeixinRoutes()
  80. {
  81. Route::prefix('wxapi')
  82. ->middleware('api')
  83. ->namespace($this->namespace)
  84. ->group(base_path('routes/weixin.php'));
  85. }
  86. protected function mapMaycurRoutes()
  87. {
  88. Route::prefix('maycur')
  89. ->middleware('api')
  90. ->namespace($this->namespace)
  91. ->group(base_path('routes/maycur.php'));
  92. }
  93. }