Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can replace it with

return $this->orderByPivot($column, 'desc');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also logical.

}

/**
* Find a related model by its primary key or return a new instance of the related model.
*
Expand Down
Loading