added queryOrder function

This commit is contained in:
vedatakd 2020-11-05 11:02:18 +03:00
parent dd3548d868
commit f492342c47

View File

@ -58,9 +58,8 @@ class AjaxController extends PublicController
if ($this->request->id) if ($this->request->id)
return $this->country_model->find($this->request->id); return $this->country_model->find($this->request->id);
else { else {
$sorting_type = setting_value('visiosoft.module.location::sorting_type'); $query = $this->country_model;
$sorting_column = setting_value('visiosoft.module.location::sorting_column'); return $this->queryOrder($query);
return $this->country_model->orderBy($sorting_column, $sorting_type)->get();
} }
} }
@ -73,10 +72,7 @@ class AjaxController extends PublicController
$id = explode(',', $this->request->id); $id = explode(',', $this->request->id);
$query = $this->city_model->whereIn('parent_country_id', $id); $query = $this->city_model->whereIn('parent_country_id', $id);
$sorting_type = setting_value('visiosoft.module.location::sorting_type'); return $this->queryOrder($query);
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
return $query->orderBy($sorting_column, $sorting_type)->get();
} }
} }
@ -90,10 +86,7 @@ class AjaxController extends PublicController
$query = $this->district_model->whereIn('parent_city_id', $id); $query = $this->district_model->whereIn('parent_city_id', $id);
$sorting_type = setting_value('visiosoft.module.location::sorting_type'); return $this->queryOrder($query);
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
return $query->orderBy($sorting_column, $sorting_type)->get();
} }
} }
@ -107,10 +100,7 @@ class AjaxController extends PublicController
$query = $this->neighborhood_model->whereIn('parent_district_id', $id); $query = $this->neighborhood_model->whereIn('parent_district_id', $id);
$sorting_type = setting_value('visiosoft.module.location::sorting_type'); return $this->queryOrder($query);
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
return $query->orderBy($sorting_column, $sorting_type)->get();
} }
} }
@ -124,11 +114,7 @@ class AjaxController extends PublicController
$query = $this->village_model->whereIn('parent_neighborhood_id', $id); $query = $this->village_model->whereIn('parent_neighborhood_id', $id);
$sorting_type = setting_value('visiosoft.module.location::sorting_type'); return $this->queryOrder($query);
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
return $query->orderBy($sorting_column, $sorting_type)->get();
} }
} }
@ -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();
}
} }