diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index c06da80ce42a..ecf42f66d396 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -585,6 +585,17 @@ public function orderByPivot($column, $direction = 'asc') return $this->orderBy($this->qualifyPivotColumn($column), $direction); } + /** + * Add an "order by desc" clause for a pivot table column. + * + * @param string|\Illuminate\Contracts\Database\Query\Expression $column + * @return $this + */ + public function orderByPivotDesc($column) + { + return $this->orderBy($this->qualifyPivotColumn($column), 'desc'); + } + /** * Find a related model by its primary key or return a new instance of the related model. *