From 428e5ba3a093743dc7ef0fd727461f13d65c8de0 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 28 Jan 2026 03:42:14 -0600 Subject: [PATCH] Functioning client list --- .../views/components/⚡client-list.blade.php | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/resources/views/components/⚡client-list.blade.php b/resources/views/components/⚡client-list.blade.php index eaade74..26e69f7 100644 --- a/resources/views/components/⚡client-list.blade.php +++ b/resources/views/components/⚡client-list.blade.php @@ -2,36 +2,61 @@ use App\Models\Client; use Livewire\Component; +use Livewire\Attributes\Computed; +use Livewire\WithPagination; + new class extends Component { + use WithPagination; + + public string $sortBy = 'abbreviation'; + public string $sortDirection = 'desc'; + + public function sort($column): void + { + if ($this->sortBy === $column) { + $this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc'; + } else { + $this->sortBy = $column; + $this->sortDirection = 'asc'; + } + } + #[Computed] public function clients() { - return Client::all(); + return Client::orderBy($this->sortBy, $this->sortDirection)->paginate(10); } }; ?>
- + - Name - + + Name + + Abbreviation - + Audition Date - + Status - + Created - @foreach($this->clients() as $client) + @foreach($this->clients as $client) {{ $client->name }} {{ $client->abbreviation }}