<?php
 namespace App\Providers; use App\Models\ClientDomain; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Http\Request; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { public const HOME = '/clientarea/dashboard'; public const ADMIN_HOME = '/admin/dashboard'; public function boot(): void { Route::bind('domain', function ($value) { return ClientDomain::findOrFail($value); }); RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); RateLimiter::for('admin-login', function (Request $request) { if (! app()->environment('production')) { return Limit::perMinute(100)->by($request->ip()); } return [ Limit::perMinute(20)->by($request->ip()), Limit::perMinute(5)->by(strtolower((string) $request->input('email'))), ]; }); RateLimiter::for('2fa-verify', function (Request $request) { $userKey = $request->user('admin')?->id ?? $request->user('client')?->id ?? null; if (! app()->environment('production')) { return Limit::perMinute(100)->by($userKey ? 'user:' . $userKey : 'ip:' . $request->ip()); } return [ $userKey ? Limit::perMinute(5)->by('user:' . $userKey) : Limit::perMinute(5)->by('ip:' . $request->ip()), Limit::perMinute(20)->by($request->ip()), ]; }); RateLimiter::for('store-login', function (Request $request) { return Limit::perMinute(app()->environment('production') ? 5 : 100) ->by($request->ip()); }); $this->routes(function () { Route::middleware('install') ->group(base_path('routes/install.php')); Route::middleware('api') ->prefix('api') ->group(base_path('routes/api.php')); Route::prefix('storeapi') ->group(base_path('routes/storeapi.php')); Route::middleware('web') ->group(base_path('routes/web.php')); }); } } 