| 
1 |  | -<?php  | 
2 |  | - | 
3 |  | -namespace Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings;  | 
4 |  | - | 
5 |  | -trait HasQueryStringForSort  | 
6 |  | -{  | 
7 |  | - | 
8 |  | -    protected function queryStringHasQueryStringForSort(): array  | 
9 |  | -    {  | 
10 |  | -        return ($this->queryStringForSortEnabled() && $this->sortingIsEnabled()) ? ['sorts' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForSort()]] : [];  | 
11 |  | - | 
12 |  | -    }  | 
13 |  | -    public function setupQueryStringStatusForSort(): void  | 
14 |  | -    {  | 
15 |  | -        if (! $this->hasQueryStringStatusForSort()) {  | 
16 |  | -            $this->setQueryStringForSortEnabled();  | 
17 |  | -        }  | 
18 |  | -    }  | 
19 |  | - | 
20 |  | -    protected function hasQueryStringStatusForSort(): bool  | 
21 |  | -    {  | 
22 |  | -        return $this->hasQueryStringConfigStatus('sorts');  | 
23 |  | -    }  | 
24 |  | - | 
25 |  | -    protected function getQueryStringStatusForSort(): bool  | 
26 |  | -    {  | 
27 |  | -        return $this->getQueryStringConfigStatus("sorts");  | 
28 |  | -    }  | 
29 |  | - | 
30 |  | -    protected function queryStringForSortEnabled(): bool  | 
31 |  | -    {  | 
32 |  | -        $this->setupQueryStringStatusForSort();  | 
33 |  | - | 
34 |  | -        return $this->getQueryStringStatusForSort() && $this->sortingIsEnabled();  | 
35 |  | -    }  | 
36 |  | - | 
37 |  | -    public function setQueryStringStatusForSort(bool $status): self  | 
38 |  | -    {  | 
39 |  | -        return $this->setQueryStringConfigStatus("sorts", $status);  | 
40 |  | -    }  | 
41 |  | - | 
42 |  | -    public function setQueryStringForSortEnabled(): self  | 
43 |  | -    {  | 
44 |  | -        return $this->setQueryStringStatusForSort(true);  | 
45 |  | -    }  | 
46 |  | - | 
47 |  | -    public function setQueryStringForSortDisabled(): self  | 
48 |  | -    {  | 
49 |  | -        return $this->setQueryStringStatusForSort(false);  | 
50 |  | -    }  | 
51 |  | - | 
52 |  | -    protected function hasQueryStringAliasForSort(): bool  | 
53 |  | -    {  | 
54 |  | -        return $this->hasQueryStringConfigAlias('sorts');  | 
55 |  | -    }  | 
56 |  | - | 
57 |  | -    protected function getQueryStringAliasForSort(): string  | 
58 |  | -    {  | 
59 |  | -        return $this->getQueryStringConfigAlias("sorts");  | 
60 |  | -    }  | 
61 |  | - | 
62 |  | -    public function setQueryStringAliasForSort(string $alias): self  | 
63 |  | -    {  | 
64 |  | -        return $this->setQueryStringConfigAlias("sorts", $alias);  | 
65 |  | -    }  | 
66 |  | -}  | 
 | 1 | +<?php  | 
 | 2 | + | 
 | 3 | +namespace Rappasoft\LaravelLivewireTables\Traits\Core\QueryStrings;  | 
 | 4 | + | 
 | 5 | +trait HasQueryStringForSort  | 
 | 6 | +{  | 
 | 7 | +    protected function queryStringHasQueryStringForSort(): array  | 
 | 8 | +    {  | 
 | 9 | +        return ($this->queryStringForSortEnabled() && $this->sortingIsEnabled()) ? ['sorts' => ['except' => null, 'history' => false, 'keep' => false, 'as' => $this->getQueryStringAliasForSort()]] : [];  | 
 | 10 | + | 
 | 11 | +    }  | 
 | 12 | + | 
 | 13 | +    public function setupQueryStringStatusForSort(): void  | 
 | 14 | +    {  | 
 | 15 | +        if (! $this->hasQueryStringStatusForSort()) {  | 
 | 16 | +            $this->setQueryStringForSortEnabled();  | 
 | 17 | +        }  | 
 | 18 | +    }  | 
 | 19 | + | 
 | 20 | +    protected function hasQueryStringStatusForSort(): bool  | 
 | 21 | +    {  | 
 | 22 | +        return $this->hasQueryStringConfigStatus('sorts');  | 
 | 23 | +    }  | 
 | 24 | + | 
 | 25 | +    protected function getQueryStringStatusForSort(): bool  | 
 | 26 | +    {  | 
 | 27 | +        return $this->getQueryStringConfigStatus('sorts');  | 
 | 28 | +    }  | 
 | 29 | + | 
 | 30 | +    protected function queryStringForSortEnabled(): bool  | 
 | 31 | +    {  | 
 | 32 | +        $this->setupQueryStringStatusForSort();  | 
 | 33 | + | 
 | 34 | +        return $this->getQueryStringStatusForSort() && $this->sortingIsEnabled();  | 
 | 35 | +    }  | 
 | 36 | + | 
 | 37 | +    public function setQueryStringStatusForSort(bool $status): self  | 
 | 38 | +    {  | 
 | 39 | +        return $this->setQueryStringConfigStatus('sorts', $status);  | 
 | 40 | +    }  | 
 | 41 | + | 
 | 42 | +    public function setQueryStringForSortEnabled(): self  | 
 | 43 | +    {  | 
 | 44 | +        return $this->setQueryStringStatusForSort(true);  | 
 | 45 | +    }  | 
 | 46 | + | 
 | 47 | +    public function setQueryStringForSortDisabled(): self  | 
 | 48 | +    {  | 
 | 49 | +        return $this->setQueryStringStatusForSort(false);  | 
 | 50 | +    }  | 
 | 51 | + | 
 | 52 | +    protected function hasQueryStringAliasForSort(): bool  | 
 | 53 | +    {  | 
 | 54 | +        return $this->hasQueryStringConfigAlias('sorts');  | 
 | 55 | +    }  | 
 | 56 | + | 
 | 57 | +    protected function getQueryStringAliasForSort(): string  | 
 | 58 | +    {  | 
 | 59 | +        return $this->getQueryStringConfigAlias('sorts');  | 
 | 60 | +    }  | 
 | 61 | + | 
 | 62 | +    public function setQueryStringAliasForSort(string $alias): self  | 
 | 63 | +    {  | 
 | 64 | +        return $this->setQueryStringConfigAlias('sorts', $alias);  | 
 | 65 | +    }  | 
 | 66 | +}  | 
0 commit comments