RouteServiceProvider.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Cache\RateLimiting\Limit;
  4. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\RateLimiter;
  7. use Illuminate\Support\Facades\Route;
  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 = '/forms';
  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. *
  32. */
  33. protected $namespace = 'App\Http\Controllers';
  34. public function boot()
  35. {
  36. $this->configureRateLimiting();
  37. $this->routes(function () {
  38. Route::prefix('api')
  39. ->middleware('api')
  40. ->namespace($this->namespace)
  41. ->group(base_path('routes/api.php'));
  42. Route::middleware('web')
  43. ->namespace($this->namespace)
  44. ->group(base_path('routes/web.php'));
  45. });
  46. }
  47. /**
  48. * Configure the rate limiters for the application.
  49. *
  50. * @return void
  51. */
  52. protected function configureRateLimiting()
  53. {
  54. RateLimiter::for('api', function (Request $request) {
  55. return Limit::perMinute(60);
  56. });
  57. }
  58. }