Skip to content

Commit

Permalink
feat: add desc sorting for ManualOrderSorter
Browse files Browse the repository at this point in the history
  • Loading branch information
reinvanoyen committed Sep 18, 2024
1 parent 4652957 commit fd8ac64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Sorters/ManualOrderSorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ class ManualOrderSorter extends Sorter
private string $column;

/**
* ManualOrderSorter constructor.
* @var string $sortMethod
*/
private string $sortMethod;

/**
* @param string $column
* @param string $sortMethod
*/
public function __construct(string $column)
public function __construct(string $column, string $sortMethod = 'asc')
{
$this->column = $column;
$this->sortMethod = $sortMethod;
}

/**
Expand All @@ -39,7 +45,7 @@ public function type(): string
*/
public function apply(Request $request, $query)
{
return $query->orderBy($this->column, 'asc');
return $query->orderBy($this->column, $this->sortMethod);
}

/**
Expand Down

0 comments on commit fd8ac64

Please sign in to comment.