RouteServiceProvider.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = '/';
  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->mapHomeRoutes();
  40. $this->mapPanelRoutes();
  41. //
  42. }
  43. /**
  44. * Define the "web" routes for the application.
  45. *
  46. * These routes all receive session state, CSRF protection, etc.
  47. *
  48. * @return void
  49. */
  50. protected function mapHomeRoutes()
  51. {
  52. Route::middleware('web')
  53. ->namespace($this->namespace)
  54. ->group(base_path('routes/home/web.php'));
  55. }
  56. /**
  57. * Define the "api" routes for the application.
  58. *
  59. * These routes are typically stateless.
  60. *
  61. * @return void
  62. */
  63. protected function mapApiRoutes()
  64. {
  65. Route::prefix('api')
  66. ->middleware('api')
  67. ->namespace($this->namespace)
  68. ->group(base_path('routes/api.php'));
  69. }
  70. protected function mapPanelRoutes()
  71. {
  72. Route::middleware(['web', 'auth', 'verified'])
  73. ->namespace($this->namespace.'\Panel')
  74. ->prefix('panel')
  75. ->group(base_path('routes/panel/web.php'));
  76. }
  77. }