領収証発行サービス
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6KB

  1. <?php
  2. namespace App\Providers;
  3. use App\Codes\EnvironmentName;
  4. use Illuminate\Cache\RateLimiting\Limit;
  5. use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\RateLimiter;
  8. use Illuminate\Support\Facades\Route;
  9. class RouteServiceProvider extends ServiceProvider
  10. {
  11. /**
  12. * The path to the "home" route for your application.
  13. *
  14. * Typically, users are redirected here after authentication.
  15. *
  16. * @var string
  17. */
  18. public const HOME = '/home';
  19. /**
  20. * Define your route model bindings, pattern filters, and other route configuration.
  21. */
  22. public function boot(): void
  23. {
  24. $this->configureRateLimiting();
  25. $this->routes(function () {
  26. Route::middleware('web')
  27. ->prefix('api')
  28. ->group(base_path('routes/api.php'));
  29. Route::middleware('web')
  30. ->group(base_path('routes/web.php'));
  31. if (app()->environment([EnvironmentName::LOCAL->value])) {
  32. Route::prefix('test')
  33. ->group(base_path('routes/test.php'));
  34. }
  35. });
  36. }
  37. /**
  38. * Configure the rate limiters for the application.
  39. */
  40. protected function configureRateLimiting(): void
  41. {
  42. RateLimiter::for('api', function (Request $request) {
  43. return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
  44. });
  45. RateLimiter::for('web', function (Request $request) {
  46. return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
  47. });
  48. }
  49. }