File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -192,11 +192,10 @@ protected function getHasManyDeepForeignKey($model): string
192192
193193 // Fallback: try to infer from intermediate model or use related model's key
194194 $ intermediateTable = $ this ->getHasManyDeepIntermediateTable ($ model );
195- $ fallbackKey = $ intermediateTable
195+
196+ return $ intermediateTable
196197 ? \Illuminate \Support \Str::singular ($ intermediateTable ).'_id '
197198 : $ model ->getRelated ()->getKeyName ();
198-
199- return $ fallbackKey ;
200199 }
201200
202201 /**
@@ -221,15 +220,14 @@ protected function getHasManyDeepLocalKey($model): string
221220 // Fallback: use the intermediate model's key name, or parent if no intermediate
222221 $ intermediateTable = $ this ->getHasManyDeepIntermediateTable ($ model );
223222 $ through = $ this ->getThroughModels ($ model );
224- $ fallbackKey = $ model ->getParent ()->getKeyName ();
225223 if ($ intermediateTable && ! empty ($ through )) {
226224 $ firstThrough = is_string ($ through [0 ]) ? $ through [0 ] : get_class ($ through [0 ]);
227225 if (class_exists ($ firstThrough )) {
228- $ fallbackKey = app ($ firstThrough )->getKeyName ();
226+ return app ($ firstThrough )->getKeyName ();
229227 }
230228 }
231229
232- return $ fallbackKey ;
230+ return $ model -> getParent ()-> getKeyName () ;
233231 }
234232
235233 /**
You can’t perform that action at this time.
0 commit comments