| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Traits\Concatenation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Database\Eloquent\Builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Database\Eloquent\Collection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Database\Eloquent\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | trait IsConcatenableAncestorsRelation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     use IsConcatenableRelation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * Set the constraints for an eager load of the deep relation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @param \Illuminate\Database\Eloquent\Builder $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @param array $models | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 | 30 |  |     public function addEagerConstraintsToDeepRelationship(Builder $query, array $models): void | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 | 30 |  |         $this->addEagerConstraints($models); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 | 30 |  |         $this->mergeExpressions($query, $this->query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * Match the eagerly loaded results for a deep relationship to their parents. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param array $models | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @param \Illuminate\Database\Eloquent\Collection $results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @param string $relation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param string $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 30 |  |     public function matchResultsForDeepRelationship( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         array $models, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         Collection $results, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         string $relation, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         string $type = 'many' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     ): array { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 30 |  |         $dictionary = $this->buildDictionaryForDeepRelationship($results); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 30 |  |         $attribute = $this->andSelf ? $this->localKey : $this->getForeignKeyName(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 30 |  |         foreach ($models as $model) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 30 |  |             $key = $model->$attribute; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 30 |  |             if (isset($dictionary[$key])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 30 |  |                 $value = $dictionary[$key]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 30 |  |                 $value = $type === 'one' ? reset($value) : $this->related->newCollection($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 30 |  |                 $model->setRelation($relation, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 30 |  |         return $models; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * Build the model dictionary for a deep relation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @param \Illuminate\Database\Eloquent\Collection $results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 30 |  |     protected function buildDictionaryForDeepRelationship(Collection $results): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 30 |  |         $pathSeparator = $this->related->getPathSeparator(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 30 |  |         return $results->mapToDictionary(function (Model $result) use ($pathSeparator) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 30 |  |             $key = strtok($result->laravel_through_key, $pathSeparator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 30 |  |             return [$key => $result]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 30 |  |         })->all(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 77 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.