user(); if (! $user) { return $next($request); } $organization = $this->organizations->resolveForUser($user); if (! $organization || $this->plans->hasPaidPlan($organization)) { return $next($request); } if ($request->expectsJson() || $request->ajax()) { return response()->json([ 'message' => 'This feature requires Care Pro or Enterprise.', 'upgrade_url' => route('care.pro.index'), ], 402); } return redirect() ->route('care.pro.index') ->with('upsell', 'Lab, pharmacy, billing, and Queue integration are part of Care Pro. Upgrade to unlock them.'); } }