File tree 1 file changed +8
-1
lines changed
src/Illuminate/Database/Eloquent
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11
11
use Illuminate \Contracts \Support \Jsonable ;
12
12
use Illuminate \Database \ConnectionResolverInterface as Resolver ;
13
13
use Illuminate \Database \Eloquent \Relations \Concerns \AsPivot ;
14
+ use Illuminate \Database \Eloquent \Relations \HasManyThrough ;
14
15
use Illuminate \Database \Eloquent \Relations \Pivot ;
15
16
use Illuminate \Support \Arr ;
16
17
use Illuminate \Support \Collection as BaseCollection ;
@@ -1522,7 +1523,13 @@ public function resolveRouteBinding($value, $field = null)
1522
1523
*/
1523
1524
public function resolveChildRouteBinding ($ childType , $ value , $ field )
1524
1525
{
1525
- return $ this ->{Str::plural (Str::camel ($ childType ))}()->where ($ field , $ value )->first ();
1526
+ $ relationship = $ this ->{Str::plural (Str::camel ($ childType ))}();
1527
+
1528
+ if ($ relationship instanceof HasManyThrough) {
1529
+ return $ relationship ->where ($ relationship ->getRelated ()->getTable ().'. ' .$ field , $ value )->first ();
1530
+ } else {
1531
+ return $ relationship ->where ($ field , $ value )->first ();
1532
+ }
1526
1533
}
1527
1534
1528
1535
/**
You can’t perform that action at this time.
0 commit comments