RouteServiceProvider.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. //
  41. }
  42. /**
  43. * Define the "web" routes for the application.
  44. *
  45. * These routes all receive session state, CSRF protection, etc.
  46. *
  47. * @return void
  48. */
  49. protected function mapWebRoutes()
  50. {
  51. Route::middleware('web')
  52. ->namespace($this->namespace)
  53. ->group(base_path('routes/web.php'));
  54. }
  55. /**
  56. * Define the "api" routes for the application.
  57. *
  58. * These routes are typically stateless.
  59. *
  60. * @return void
  61. */
  62. protected function mapApiRoutes()
  63. {
  64. Route::prefix('api')
  65. ->middleware('api')
  66. ->namespace($this->namespace)
  67. ->group(base_path('routes/api.php'));
  68. }
  69. }