@@ -163,8 +163,11 @@ protected function matchOneOrMany(array $models, Collection $results, $relation,
163163
164164 if ($ this ->key ) {
165165 foreach ($ models as $ model ) {
166+ /** @var \Illuminate\Database\Eloquent\Collection<int, TRelatedModel> $relatedModels */
167+ $ relatedModels = $ model ->$ relation ;
168+
166169 $ this ->hydratePivotRelation (
167- $ model -> $ relation ,
170+ $ relatedModels ,
168171 $ model ,
169172 fn (Model $ model ) => $ model ->{$ this ->getPathName ()}
170173 );
@@ -182,7 +185,10 @@ protected function buildDictionary(Collection $results)
182185 $ dictionary = [];
183186
184187 foreach ($ results as $ result ) {
185- foreach ($ result ->{$ foreign } as $ value ) {
188+ /** @var list<int|string|null> $foreignKeys */
189+ $ foreignKeys = $ result ->$ foreign ;
190+
191+ foreach ($ foreignKeys as $ value ) {
186192 $ dictionary [$ value ][] = $ result ;
187193 }
188194 }
@@ -297,7 +303,7 @@ protected function relationExistenceQueryParentKey(Builder $query): array
297303 *
298304 * @param TRelatedModel $model
299305 * @param TDeclaringModel $parent
300- * @param list< array<string, mixed>> $records
306+ * @param array<int, array<string, mixed>> $records
301307 * @return array<string, mixed>
302308 */
303309 public function pivotAttributes (Model $ model , Model $ parent , array $ records )
@@ -315,7 +321,10 @@ public function pivotAttributes(Model $model, Model $parent, array $records)
315321 return Arr::get ($ value , $ key ) == $ parent ->$ localKey ;
316322 })->first ();
317323
318- return Arr::except ($ record , $ key );
324+ /** @var array<string, mixed> $result */
325+ $ result = Arr::except ($ record , $ key );
326+
327+ return $ result ;
319328 }
320329
321330 /**
0 commit comments