From f492342c47d045149a9918360c17d6e9f39ebc6b Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 5 Nov 2020 11:02:18 +0300 Subject: [PATCH] added queryOrder function --- .../src/Http/Controller/AjaxController.php | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php index c8f7d570f..0ac30691e 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php @@ -58,9 +58,8 @@ class AjaxController extends PublicController if ($this->request->id) return $this->country_model->find($this->request->id); else { - $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); - return $this->country_model->orderBy($sorting_column, $sorting_type)->get(); + $query = $this->country_model; + return $this->queryOrder($query); } } @@ -73,10 +72,7 @@ class AjaxController extends PublicController $id = explode(',', $this->request->id); $query = $this->city_model->whereIn('parent_country_id', $id); - $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); - - return $query->orderBy($sorting_column, $sorting_type)->get(); + return $this->queryOrder($query); } } @@ -90,10 +86,7 @@ class AjaxController extends PublicController $query = $this->district_model->whereIn('parent_city_id', $id); - $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); - - return $query->orderBy($sorting_column, $sorting_type)->get(); + return $this->queryOrder($query); } } @@ -107,10 +100,7 @@ class AjaxController extends PublicController $query = $this->neighborhood_model->whereIn('parent_district_id', $id); - $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); - - return $query->orderBy($sorting_column, $sorting_type)->get(); + return $this->queryOrder($query); } } @@ -124,11 +114,7 @@ class AjaxController extends PublicController $query = $this->village_model->whereIn('parent_neighborhood_id', $id); - $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); - - return $query->orderBy($sorting_column, $sorting_type)->get(); - + return $this->queryOrder($query); } } @@ -146,4 +132,12 @@ class AjaxController extends PublicController } } } + + public function queryOrder($query) + { + $sorting_type = setting_value('visiosoft.module.location::sorting_type'); + $sorting_column = setting_value('visiosoft.module.location::sorting_column'); + + return $query->orderBy($sorting_column, $sorting_type)->get(); + } } \ No newline at end of file