RouteServiceProvider.php 1.2 KB

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