RouteServiceProvider.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. if (config('app.env') !== 'local') {
  31. // \URL::forceScheme('http');
  32. }
  33. }
  34. /**
  35. * Define the routes for the application.
  36. *
  37. * @return void
  38. */
  39. public function map()
  40. {
  41. $this->mapApiRoutes();
  42. $this->mapWebRoutes();
  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. }