techblog/app/Livewire/IncludesSorting.php
PeterChrz 75561faf25
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
initialize project and update gitignore
2026-03-19 09:35:42 -04:00

20 lines
428 B
PHP

<?php
namespace App\Livewire;
trait IncludesSorting
{
public ?string $sortBy = null;
public string $sortDirection = 'asc';
public function sort(string $column): void
{
if ($this->sortBy === $column) {
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
} else {
$this->sortBy = $column;
$this->sortDirection = 'desc';
}
}
}