@@ -165,14 +165,14 @@ protected function addRelated($rows): ?array
165165 // If there were no matches then reset per-query data and quit
166166 if (empty ($ rows ))
167167 {
168- unset($ this ->tmpWith , $ this ->tmpWith );
168+ unset($ this ->tmpWith , $ this ->tmpWithout );
169169 return $ rows ;
170170 }
171171
172172 // Likewise for empty singletons
173173 if (count ($ rows ) == 1 && reset ($ rows ) == null )
174174 {
175- unset($ this ->tmpWith , $ this ->tmpWith );
175+ unset($ this ->tmpWith , $ this ->tmpWithout );
176176 return $ rows ;
177177 }
178178
@@ -193,7 +193,7 @@ protected function addRelated($rows): ?array
193193 // If tmpWith ends up empty then reset and quit
194194 if (empty ($ this ->tmpWith ))
195195 {
196- unset($ this ->tmpWith , $ this ->tmpWith );
196+ unset($ this ->tmpWith , $ this ->tmpWithout );
197197 return $ this ->simpleReindex ($ rows );
198198 }
199199
@@ -261,7 +261,7 @@ protected function addRelated($rows): ?array
261261 }
262262
263263 // Clear old data and reset per-query properties
264- unset($ rows , $ this ->tmpWith , $ this ->tmpWith );
264+ unset($ rows , $ this ->tmpWith , $ this ->tmpWithout );
265265
266266 return $ return ;
267267 }
@@ -313,9 +313,10 @@ public function findRelated($tableName, $ids): array
313313 // If nesting is allowed we need to disable the target table
314314 if (self ::$ config ->allowNesting )
315315 {
316- // Add the table to the "without" list
317- $ this ->without ($ table ->name );
318- $ builder ->without ($ this ->tmpWithout );
316+ // Add the target table to the "without" list
317+ $ without = $ this ->tmpWithout ?? [];
318+ $ without [] = $ table ->name ;
319+ $ builder ->without ($ without );
319320 }
320321 // Otherwise turn off relation loading on returned relations
321322 else
0 commit comments