|
2 | 2 |
|
3 | 3 | namespace Greensight\LaravelElasticQuery\Raw\Concerns; |
4 | 4 |
|
| 5 | +use Greensight\LaravelElasticQuery\Raw\Contracts\SortMode; |
| 6 | +use Greensight\LaravelElasticQuery\Raw\Contracts\SortOrder; |
| 7 | + |
5 | 8 | /** |
6 | 9 | * @psalm-require-implements \Greensight\LaravelElasticQuery\Raw\Contracts\SortableQuery |
7 | 10 | * |
8 | | - * @method static sortBy(string $field, string $order = 'asc', ?string $mode = null) |
| 11 | + * @method static sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null) |
9 | 12 | */ |
10 | 13 | trait ExtendsSort |
11 | 14 | { |
12 | | - public function minSortBy(string $field, string $order = 'asc'): static |
| 15 | + public function minSortBy(string $field, string $order = SortOrder::ASC): static |
13 | 16 | { |
14 | | - return $this->sortBy($field, $order, 'min'); |
| 17 | + return $this->sortBy($field, $order, SortMode::MIN); |
15 | 18 | } |
16 | 19 |
|
17 | | - public function maxSortBy(string $field, string $order = 'asc'): static |
| 20 | + public function maxSortBy(string $field, string $order = SortOrder::ASC): static |
18 | 21 | { |
19 | | - return $this->sortBy($field, $order, 'max'); |
| 22 | + return $this->sortBy($field, $order, SortMode::MAX); |
20 | 23 | } |
21 | 24 |
|
22 | | - public function avgSortBy(string $field, string $order = 'asc'): static |
| 25 | + public function avgSortBy(string $field, string $order = SortOrder::ASC): static |
23 | 26 | { |
24 | | - return $this->sortBy($field, $order, 'avg'); |
| 27 | + return $this->sortBy($field, $order, SortMode::AVG); |
25 | 28 | } |
26 | 29 |
|
27 | | - public function sumSortBy(string $field, string $order = 'asc'): static |
| 30 | + public function sumSortBy(string $field, string $order = SortOrder::ASC): static |
28 | 31 | { |
29 | | - return $this->sortBy($field, $order, 'sum'); |
| 32 | + return $this->sortBy($field, $order, SortMode::SUM); |
30 | 33 | } |
31 | 34 |
|
32 | | - public function medianSortBy(string $field, string $order = 'asc'): static |
| 35 | + public function medianSortBy(string $field, string $order = SortOrder::ASC): static |
33 | 36 | { |
34 | | - return $this->sortBy($field, $order, 'median'); |
| 37 | + return $this->sortBy($field, $order, SortMode::MEDIAN); |
35 | 38 | } |
36 | 39 | } |
0 commit comments