RouteServiceProvider.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Support\Facades\Route;
  4. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  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. * Define your route model bindings, pattern filters, etc.
  17. *
  18. * @return void
  19. */
  20. public function boot()
  21. {
  22. //
  23. parent::boot();
  24. }
  25. /**
  26. * Define the routes for the application.
  27. *
  28. * @return void
  29. */
  30. public function map()
  31. {
  32. $this->mapWebRoutes();
  33. $this->mapApiRoutes();
  34. //
  35. }
  36. /**
  37. * Define the "web" routes for the application.
  38. *
  39. * These routes all receive session state, CSRF protection, etc.
  40. *
  41. * @return void
  42. */
  43. protected function mapWebRoutes()
  44. {
  45. Route::group([
  46. 'middleware' => 'web',
  47. 'namespace' => $this->namespace,
  48. ], function ($router) {
  49. require base_path('routes/web.php');
  50. });
  51. }
  52. /**
  53. * Define the "api" routes for the application.
  54. *
  55. * These routes are typically stateless.
  56. *
  57. * @return void
  58. */
  59. protected function mapApiRoutes()
  60. {
  61. Route::group([
  62. 'middleware' => 'api',
  63. 'namespace' => $this->namespace,
  64. 'prefix' => 'api',
  65. ], function ($router) {
  66. require base_path('routes/api.php');
  67. });
  68. }
  69. }