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) { if (\ctype_digit($value)) { $customer = Customer::where('id', '=', $value)->firstOrFail(); } if (!isset($customer) and strpos($value, '@') !== false) { $customer = Customer::where('email', '=', $value)->firstOrFail(); } if (!isset($customer)) { try { $customer = CustomerInfo::with('customer') ->where('hashcode', $value)->firstOrFail()->customer; } catch (ModelNotFoundException $e) { // Uniform Not found exception using model Customer throw (new ModelNotFoundException())->setModel(Customer::class); } } if ($brand = app('App\Models\Service')->brand) { /** @var \App\Models\Customer $customer */ $customer = $customer->loadBrandData($brand); } return $customer; }); } /** * 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()); }); } }