From 9d9b59ffc52bc7e5e842cb3776c380731984452e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 21 Jun 2023 22:42:11 +1000 Subject: [PATCH] Sort invoices by client --- app/Filters/InvoiceFilters.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 9460026c63ef..07dd8619d71b 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -204,6 +204,14 @@ class InvoiceFilters extends QueryFilters return $this->builder; } + if ($sort_col[0] == 'client_id') { + + $this->builder->with(['client' => function($q) use($sort_col){ + $q->orderBy('name', $sort_col[1]); + }]); + + } + return $this->builder->orderBy($sort_col[0], $sort_col[1]); }