RouteServiceProvider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 = '/idara/presentations';
  18. /**
  19. * Define your route model bindings, pattern filters, etc.
  20. *
  21. * @return void
  22. */
  23. public function boot()
  24. {
  25. $this->configureRateLimiting();
  26. $this->routes(function () {
  27. Route::prefix('api')
  28. ->middleware('api')
  29. ->namespace($this->namespace)
  30. ->group(base_path('routes/api.php'));
  31. Route::middleware('web')
  32. ->namespace($this->namespace)
  33. ->group(base_path('routes/web.php'));
  34. });
  35. }
  36. /**
  37. * Configure the rate limiters for the application.
  38. *
  39. * @return void
  40. */
  41. protected function configureRateLimiting()
  42. {
  43. RateLimiter::for('api', function (Request $request) {
  44. return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
  45. });
  46. }
  47. }