diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index e5d700e59bd8..d15b70ddccbe 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -362,7 +362,7 @@ public function wherePivot($column, $operator = null, $value = null, $boolean = { $this->pivotWheres[] = func_get_args(); - return $this->where($this->qualifyColumn($column), $operator, $value, $boolean); + return $this->where($this->qualifyPivotColumn($column), $operator, $value, $boolean); } /** @@ -376,7 +376,7 @@ public function wherePivot($column, $operator = null, $value = null, $boolean = */ public function wherePivotBetween($column, array $values, $boolean = 'and', $not = false) { - return $this->whereBetween($this->qualifyColumn($column), $values, $boolean, $not); + return $this->whereBetween($this->qualifyPivotColumn($column), $values, $boolean, $not); } /** @@ -429,7 +429,7 @@ public function wherePivotIn($column, $values, $boolean = 'and', $not = false) { $this->pivotWhereIns[] = func_get_args(); - return $this->whereIn($this->qualifyColumn($column), $values, $boolean, $not); + return $this->whereIn($this->qualifyPivotColumn($column), $values, $boolean, $not); } /** @@ -524,7 +524,7 @@ public function wherePivotNull($column, $boolean = 'and', $not = false) { $this->pivotWhereNulls[] = func_get_args(); - return $this->whereNull($this->qualifyColumn($column), $boolean, $not); + return $this->whereNull($this->qualifyPivotColumn($column), $boolean, $not); } /** @@ -810,7 +810,7 @@ protected function aliasedPivotColumns() $defaults = [$this->foreignPivotKey, $this->relatedPivotKey]; return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) { - return $this->qualifyColumn($column).' as pivot_'.$column; + return $this->qualifyPivotColumn($column).' as pivot_'.$column; })->unique()->all(); } @@ -1230,7 +1230,7 @@ public function getForeignPivotKeyName() */ public function getQualifiedForeignPivotKeyName() { - return $this->qualifyColumn($this->foreignPivotKey); + return $this->qualifyPivotColumn($this->foreignPivotKey); } /** @@ -1250,7 +1250,7 @@ public function getRelatedPivotKeyName() */ public function getQualifiedRelatedPivotKeyName() { - return $this->qualifyColumn($this->relatedPivotKey); + return $this->qualifyPivotColumn($this->relatedPivotKey); } /** @@ -1339,7 +1339,7 @@ public function getPivotColumns() * @param string $column * @return string */ - public function qualifyColumn($column) + public function qualifyPivotColumn($column) { return Str::contains($column, '.') ? $column diff --git a/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php b/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php index ec456816004c..c2d574558224 100644 --- a/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php @@ -68,7 +68,7 @@ protected function addWhereConstraints() { parent::addWhereConstraints(); - $this->query->where($this->qualifyColumn($this->morphType), $this->morphClass); + $this->query->where($this->qualifyPivotColumn($this->morphType), $this->morphClass); return $this; } @@ -83,7 +83,7 @@ public function addEagerConstraints(array $models) { parent::addEagerConstraints($models); - $this->query->where($this->qualifyColumn($this->morphType), $this->morphClass); + $this->query->where($this->qualifyPivotColumn($this->morphType), $this->morphClass); } /** @@ -111,7 +111,7 @@ protected function baseAttachRecord($id, $timed) public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*']) { return parent::getRelationExistenceQuery($query, $parentQuery, $columns)->where( - $this->qualifyColumn($this->morphType), $this->morphClass + $this->qualifyPivotColumn($this->morphType), $this->morphClass ); } @@ -173,7 +173,7 @@ protected function aliasedPivotColumns() $defaults = [$this->foreignPivotKey, $this->relatedPivotKey, $this->morphType]; return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) { - return $this->qualifyColumn($column).' as pivot_'.$column; + return $this->qualifyPivotColumn($column).' as pivot_'.$column; })->unique()->all(); }