20 lines
428 B
PHP
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';
|
|
}
|
|
}
|
|
}
|