From 2d562b0d6eb17642598409793a6a139f62008490 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 31 Mar 2025 11:04:51 +1100 Subject: [PATCH] Fixes for default sort order in Client Portal --- app/Livewire/CreditsTable.php | 6 ++++++ app/Livewire/InvoicesTable.php | 2 +- app/Livewire/PaymentsTable.php | 4 ++++ app/Livewire/QuotesTable.php | 8 ++++++-- app/Livewire/TasksTable.php | 3 +++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/Livewire/CreditsTable.php b/app/Livewire/CreditsTable.php index dcdafa45a8..ed31a848b9 100644 --- a/app/Livewire/CreditsTable.php +++ b/app/Livewire/CreditsTable.php @@ -34,6 +34,12 @@ class CreditsTable extends Component { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; + + } public function render() diff --git a/app/Livewire/InvoicesTable.php b/app/Livewire/InvoicesTable.php index 006300a354..8fe27a607b 100644 --- a/app/Livewire/InvoicesTable.php +++ b/app/Livewire/InvoicesTable.php @@ -55,7 +55,7 @@ class InvoicesTable extends Component $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc')); }) ->when($this->sort_field != 'number', function ($q){ - $q->orderBy($this->sort_field, ($this->sort_asc ? 'desc' : 'asc')); + $q->orderBy($this->sort_field, ($this->sort_asc ? 'asc' : 'desc')); }); // ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc'); diff --git a/app/Livewire/PaymentsTable.php b/app/Livewire/PaymentsTable.php index b13d08469a..197c736d5b 100644 --- a/app/Livewire/PaymentsTable.php +++ b/app/Livewire/PaymentsTable.php @@ -33,6 +33,10 @@ class PaymentsTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; } public function render() diff --git a/app/Livewire/QuotesTable.php b/app/Livewire/QuotesTable.php index 4317928708..0c2d31ca29 100644 --- a/app/Livewire/QuotesTable.php +++ b/app/Livewire/QuotesTable.php @@ -37,6 +37,10 @@ class QuotesTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + + $this->sort_field = 'date'; } @@ -55,10 +59,10 @@ class QuotesTable extends Component ->with('client.contacts', 'company') // ->orderBy($this->sort, $this->sort_asc ? 'asc' : 'desc'); ->when($this->sort == 'number', function ($q){ - $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'desc' : 'asc')); + $q->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . ($this->sort_asc ? 'asc' : 'desc')); }) ->when($this->sort != 'number', function ($q){ - $q->orderBy($this->sort, ($this->sort_asc ? 'desc' : 'asc')); + $q->orderBy($this->sort, ($this->sort_asc ? 'asc' : 'desc')); }); diff --git a/app/Livewire/TasksTable.php b/app/Livewire/TasksTable.php index 1528cfc7c6..0dafaf372b 100644 --- a/app/Livewire/TasksTable.php +++ b/app/Livewire/TasksTable.php @@ -32,6 +32,9 @@ class TasksTable extends Component public function mount() { MultiDB::setDb($this->db); + + $this->sort_asc = false; + } public function render()