user(); if (!$user) { return $next($request); } // Check if the current route is excluded foreach ($this->excludedRoutes as $excludedRoute) { if ($request->routeIs($excludedRoute)) { return $next($request); } } // Check if user needs to accept or re-accept principles if ($user->needsToReacceptPrinciples()) { // Redirect to principles page with appropriate message $principlesUrl = LaravelLocalization::localizeUrl(route('static-principles')); $message = $user->hasAcceptedPrinciples() ? __('Our principles have been updated. Please review and accept the new version to continue.') : __('Please accept the platform principles to continue.'); return redirect()->to($principlesUrl) ->with('warning', $message); } return $next($request); } }