File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
src/Illuminate/Database/Eloquent Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -79,19 +79,18 @@ public function loadCount($relations)
79
79
->whereKey ($ this ->modelKeys ())
80
80
->select ($ this ->first ()->getKeyName ())
81
81
->withCount (...func_get_args ())
82
- ->get ();
82
+ ->get ()
83
+ ->keyBy ($ this ->first ()->getKeyName ());
83
84
84
85
$ attributes = Arr::except (
85
86
array_keys ($ models ->first ()->getAttributes ()),
86
87
$ models ->first ()->getKeyName ()
87
88
);
88
89
89
- $ models ->each (function ($ model ) use ($ attributes ) {
90
- $ this ->where ($ this ->first ()->getKeyName (), $ model ->getKey ())
91
- ->each
92
- ->forceFill (Arr::only ($ model ->getAttributes (), $ attributes ))
93
- ->each
94
- ->syncOriginalAttributes ($ attributes );
90
+ $ this ->each (function ($ model ) use ($ models , $ attributes ) {
91
+ $ extraAttributes = Arr::only ($ models ->get ($ model ->getKey ())->getAttributes (), $ attributes );
92
+
93
+ $ model ->forceFill ($ extraAttributes )->syncOriginalAttributes ($ attributes );
95
94
});
96
95
97
96
return $ this ;
You can’t perform that action at this time.
0 commit comments