Inertia::lazy(fn () => Provider::whereOrganisationId($request->route('organisation'))->get()), 'registries' => Inertia::lazy(fn () => Organisation::findOrFail($request->route('organisation'))->registries()->get()), 'sourceProviders' => Inertia::lazy(fn () => Organisation::findOrFail($request->route('organisation'))->sourceProviders()->get()), 'organisation' => Organisation::with('members') ->withCount('servers', 'applications', 'members', 'providers', 'sourceProviders', 'registries') ->findOrFail($request->route('organisation')), 'health' => [ 'unhealthy_services' => Service::query() ->where('organisation_id', $request->route('organisation')) ->whereNot('status', ServiceStatus::RUNNING) ->count(), 'failed_operations' => Operation::query() ->whereHasMorph('target', [Service::class], fn ($query) => $query->where('organisation_id', $request->route('organisation'))) ->where('status', 'failed') ->count(), 'locked_variables' => Organisation::findOrFail($request->route('organisation')) ->applications() ->whereHas('environments.variables', fn ($query) => $query->where('overridable', false)) ->count(), ], ]); } }