From 7c706392e112e94e3076090b586f1cc3a2014496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Tue, 21 May 2024 23:22:49 +0300 Subject: [PATCH] fixed company list page sortable issue --- app/Models/Common/Company.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Models/Common/Company.php b/app/Models/Common/Company.php index 3bbdcc99d..135e7369b 100644 --- a/app/Models/Common/Company.php +++ b/app/Models/Common/Company.php @@ -442,6 +442,22 @@ class Company extends Eloquent implements Ownable ->select('companies.*'); } + /** + * Sort by company phone + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param $direction + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function phoneSortable($query, $direction) + { + return $query->join('settings', 'companies.id', '=', 'settings.company_id') + ->where('key', 'company.phone') + ->orderBy('value', $direction) + ->select('companies.*'); + } + /** * Sort by company tax number *