update: livewire sortBy to trait and add parameter type

This commit is contained in:
Roardom
2024-01-14 11:01:26 +00:00
parent 7037200377
commit 69cd4aa982
26 changed files with 77 additions and 353 deletions
+2 -11
View File
@@ -15,6 +15,7 @@ namespace App\Http\Livewire;
use App\Models\BonTransactions;
use App\Models\User;
use App\Traits\LivewireSort;
use Livewire\Component;
use Livewire\WithPagination;
@@ -23,6 +24,7 @@ use Livewire\WithPagination;
*/
class GiftLogSearch extends Component
{
use LivewireSort;
use WithPagination;
public string $sender = '';
@@ -75,15 +77,4 @@ class GiftLogSearch extends Component
'gifts' => $this->gifts,
]);
}
final public function sortBy($field): void
{
if ($this->sortField === $field) {
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
} else {
$this->sortDirection = 'asc';
}
$this->sortField = $field;
}
}