From 3aea292b19187462bcec22d66fc7cfae45db602c Mon Sep 17 00:00:00 2001 From: majidmohammadian Date: Wed, 20 Aug 2025 15:18:21 +0330 Subject: [PATCH] added orderByPivotDesc in BelongsToMany relation --- Eloquent/Relations/BelongsToMany.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Eloquent/Relations/BelongsToMany.php b/Eloquent/Relations/BelongsToMany.php index e125a7604..22ed4ca15 100755 --- a/Eloquent/Relations/BelongsToMany.php +++ b/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. *