Skip to content

Commit

Permalink
修复远程一对一关联到同一对象时仅成功最后一个的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
maoxuner authored and liu21st committed Jul 31, 2024
1 parent 221f661 commit 044c3ca
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/model/relation/HasOneThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 044c3ca

Please sign in to comment.