RouteServiceProvider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * The path to the "home" route for your application.
  9. *
  10. * @var string
  11. */
  12. public const HOME = '/';
  13. /**
  14. * This namespace is applied to your controller routes.
  15. *
  16. * In addition, it is set as the URL generator's root namespace.
  17. *
  18. * @var string
  19. */
  20. protected $namespace = 'App\Http\Controllers';
  21. /**
  22. * Define the routes for the application.
  23. *
  24. * @return void
  25. */
  26. public function map(): void
  27. {
  28. $this->mapApiRoutes();
  29. $this->mapWebRoutes();
  30. }
  31. /**
  32. * Define the "api" routes for the application.
  33. *
  34. * These routes are typically stateless.
  35. *
  36. * @return void
  37. */
  38. protected function mapApiRoutes(): void
  39. {
  40. Route::prefix('api')
  41. ->middleware('api')
  42. ->namespace($this->namespace)
  43. ->group(base_path('routes/api.php'));
  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(): void
  53. {
  54. Route::middleware('web')->namespace($this->namespace)->group(
  55. base_path('routes/web.php')
  56. );
  57. }
  58. }