RouteServiceProvider.php 2.2 KB

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