diff --git a/src/model/relation/HasOneThrough.php b/src/model/relation/HasOneThrough.php index bc1986cf..4394a7cf 100644 --- a/src/model/relation/HasOneThrough.php +++ b/src/model/relation/HasOneThrough.php @@ -159,13 +159,9 @@ protected function eagerlyWhere(array $where, string $key, array $subRelation = ->select(); // 组装模型数据 - $data = []; - $keys = array_flip($keys); - - foreach ($list as $set) { - $data[$keys[$set->{$this->throughKey}]] = $set; - } - - return $data; + return array_map(function ($key) use ($list) { + $set = $list->where($this->throughKey, '=', $key)->first(); + return $set ? clone $set : null; + }, $keys); } }