configureRateLimiting(); $this->routes(function () { Route::prefix('api')->middleware('api')->namespace($this->namespace)->group(base_path('routes/api.php')); Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php')); }); Route::bind('customer', function ($value) { return Customer::whereHas('infos', function ($q) use ($value) { $q->where('customer_infos.hashcode', $value); })->first() ?? (\ctype_digit($value) ? Customer::where('id', '=', $value)->first() : null) ?? Customer::where('email', '=', $value)->firstOrFail(); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(config('api.apiRequestRatePerMinute'))->by(optional($request->user())->id ?: $request->ip()); }); } }