RouteServiceProvider.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Support\Facades\Route;
  5. use Illuminate\Cache\RateLimiting\Limit;
  6. use Illuminate\Support\Facades\RateLimiter;
  7. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  8. class RouteServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * The path to the "home" route for your application.
  12. *
  13. * This is used by Laravel authentication to redirect users after login.
  14. *
  15. * @var string
  16. */
  17. public const HOME = '/home';
  18. /**
  19. * The controller namespace for the application.
  20. *
  21. * When present, controller route declarations will automatically be prefixed with this namespace.
  22. *
  23. * @var string|null
  24. */
  25. // protected $namespace = 'App\\Http\\Controllers';
  26. /**
  27. * Define your route model bindings, pattern filters, etc.
  28. *
  29. * @return void
  30. */
  31. public function boot()
  32. {
  33. $this->configureRateLimiting();
  34. $this->routes(function () {
  35. Route::prefix('dabory-app')
  36. ->middleware('api')
  37. ->namespace($this->namespace)
  38. ->group(base_path('routes/api.php'));
  39. Route::middleware('web')
  40. ->namespace($this->namespace)
  41. ->group(base_path('routes/web.php'));
  42. Route::middleware('web')
  43. ->namespace($this->namespace)
  44. ->group(base_path('routes/dabory.php'));
  45. Route::middleware('web')
  46. ->namespace($this->namespace)
  47. ->group(base_path('routes/myapp.php'));
  48. Route::middleware('web')
  49. ->namespace($this->namespace)
  50. ->group(base_path('routes/my-app.php'));
  51. Route::middleware('web')
  52. ->namespace($this->namespace)
  53. ->group(base_path('routes/shop.php'));
  54. Route::middleware('web')
  55. ->namespace($this->namespace)
  56. ->group(base_path('routes/local/file.php'));
  57. $this->mapWebRoutes();
  58. });
  59. }
  60. protected function mapWebRoutes()
  61. {
  62. // pro
  63. $langPath = public_path('themes/pro/' . env('DBR_THEME') . '/resources/lang');
  64. $this->loadTranslationsFrom($langPath, env('DBR_THEME'));
  65. $this->loadJsonTranslationsFrom($langPath);
  66. if (env('DBR_THEME')) {
  67. Route::middleware('web')
  68. ->namespace($this->namespace)
  69. ->group(daboryPath('themes/' . env('DBR_THEME') . '/pro/routes/web.php'));
  70. $erpRoutePath = 'themes/' . env('DBR_THEME') . '/erp/routes/web.php';
  71. if (file_exists(daboryPath($erpRoutePath))) {
  72. Route::middleware('web')
  73. ->namespace($this->namespace)
  74. ->group(daboryPath($erpRoutePath));
  75. }
  76. $strongErpRoutePath = 'themes/' . env('DBR_THEME') . '/strong/frontend/erp/routes/web.php';
  77. if (file_exists(daboryPath($strongErpRoutePath))) {
  78. Route::middleware('web')
  79. ->namespace($this->namespace)
  80. ->group(daboryPath($strongErpRoutePath));
  81. }
  82. $strongProRoutePath = 'themes/' . env('DBR_THEME') . '/strong/frontend/pro/routes/web.php';
  83. if (file_exists(daboryPath($strongProRoutePath))) {
  84. Route::middleware('web')
  85. ->namespace($this->namespace)
  86. ->group(daboryPath($strongProRoutePath));
  87. }
  88. $strongMyappRoutePath = 'themes/' . env('DBR_THEME') . '/strong/frontend/myapp/routes/web.php';
  89. if (file_exists(daboryPath($strongMyappRoutePath))) {
  90. Route::middleware('web')
  91. ->namespace($this->namespace)
  92. ->group(daboryPath($strongMyappRoutePath));
  93. }
  94. }
  95. // erp
  96. // $erpThemes = preg_replace('/\s+/', '', explode(',', env('ERP_THEMES')));
  97. // foreach ($erpThemes as $theme) {
  98. // if (empty($theme)) { continue; }
  99. // Route::middleware('web')
  100. // ->namespace($this->namespace)
  101. // ->group(daboryPath("themes/$theme/erp/routes/web.php"));
  102. // }
  103. }
  104. /**
  105. * Configure the rate limiters for the application.
  106. *
  107. * @return void
  108. */
  109. protected function configureRateLimiting()
  110. {
  111. RateLimiter::for('api', function (Request $request) {
  112. return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
  113. });
  114. }
  115. }