model = $request->route($modelKey); if (! $this->model instanceof Viewable) { throw new RuntimeException('record_view should only be configured for viewable models'); } return $next($request); } /** * Handle tasks after the response has been sent to the browser. */ public function terminate(Request $request, Response $response): void { if (Feature::for(null)->active(FeatureConstants::ALLOW_VIEW_RECORDING) && $this->model instanceof Viewable) { views($this->model)->cooldown(now()->addMinutes(5))->record(); } } }