user(); // 当前客户基本信息 $customerInfo = [ 'name' => $customer->name, 'phone' => $customer->phone, 'expected_date' => $customer->expected_date, 'actual_date' => $customer->actual_date, ]; // 护理档案 → 最新护理记录3条 $careProfile = CareProfile::withoutGlobalScope('store') ->where('customer_id', $customer->id) ->first(); $careRecords = []; if ($careProfile) { $careRecords = CareRecord::withoutGlobalScope('store') ->where('care_profile_id', $careProfile->id) ->with('nurse:id,name') ->latest('recorded_at') ->limit(3) ->get(); } // 今日膳食 $todayMeals = DailyMealPlan::withoutGlobalScope('store') ->where('customer_id', $customer->id) ->whereDate('plan_date', today()) ->get(); // 当前合同(最新1条) $contract = Contract::withoutGlobalScope('store') ->where('customer_id', $customer->id) ->latest() ->first(['id', 'contract_no', 'status', 'check_in_date', 'check_out_date', 'total_amount']); // 月嫂信息(进行中派单) $nannyOrder = NannyOrder::withoutGlobalScope('store') ->where('customer_id', $customer->id) ->where('status', 2) ->latest() ->first(); if ($nannyOrder) { $nannyOrder->load('nanny:id,name,level,phone'); } return $this->success([ 'customer' => $customerInfo, 'care_records' => $careRecords, 'today_meals' => $todayMeals, 'contract' => $contract, 'nanny_order' => $nannyOrder, ]); } }