forked from mahdahar/crm-summit
Update Zones Api Perbaikan hanya get cities pakai Params zoneid saja
This commit is contained in:
parent
f4961f862e
commit
34449ec836
@ -15,12 +15,12 @@ class ZonesApi extends BaseController {
|
||||
}
|
||||
|
||||
public function getProvinces() {
|
||||
$filters = [
|
||||
'zoneid' => $this->request->getVar('zoneid') ?? null,
|
||||
'zonename' => $this->request->getVar('zonename') ?? null
|
||||
];
|
||||
// $filters = [
|
||||
// 'zoneid' => $this->request->getVar('zoneid') ?? null,
|
||||
// 'zonename' => $this->request->getVar('zonename') ?? null
|
||||
// ];
|
||||
|
||||
$rows = $this->model->getAllProvinces($filters);
|
||||
$rows = $this->model->getAllProvinces();
|
||||
|
||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||
@ -28,12 +28,11 @@ class ZonesApi extends BaseController {
|
||||
|
||||
public function getCities() {
|
||||
|
||||
$filters = [
|
||||
'zoneid' => $this->request->getVar('zoneid') ?? null,
|
||||
'zonename' => $this->request->getVar('zonename') ?? null
|
||||
$filter = [
|
||||
'zoneid' => $this->request->getVar('zoneid') ?? null
|
||||
];
|
||||
|
||||
$rows = $this->model->getAllCities($filters);
|
||||
$rows = $this->model->getAllCities($filter);
|
||||
|
||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
||||
|
||||
@ -8,27 +8,24 @@ class ZonesModel extends Model {
|
||||
protected $primaryKey = 'zoneid';
|
||||
protected $allowedFields = [ 'zonecode', 'zoneclass', 'parentzoneid', 'zonename' ];
|
||||
|
||||
public function getAllProvinces($filters = []) {
|
||||
public function getAllProvinces() {
|
||||
$this->select('zoneid, zonename')->where('parentzoneid IS NULL', null, false);
|
||||
|
||||
if (!empty($filters['zoneid'])) {
|
||||
$this->where('zoneid', $filters['zoneid']);
|
||||
}
|
||||
if (!empty($filters['zonename'])) {
|
||||
$this->like('zonename', $filters['zonename'], 'both');
|
||||
}
|
||||
// if (!empty($filters['zoneid'])) {
|
||||
// $this->where('zoneid', $filters['zoneid']);
|
||||
// }
|
||||
// if (!empty($filters['zonename'])) {
|
||||
// $this->like('zonename', $filters['zonename'], 'both');
|
||||
// }
|
||||
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function getAllCities($filters = []) {
|
||||
public function getAllCities($filter = []) {
|
||||
$rows = $this->select('zoneid, zonename')->where('parentzoneid IS NOT NULL', null, false);
|
||||
|
||||
if (!empty($filters['zoneid'])) {
|
||||
$this->where('zoneid', $filters['zoneid']);
|
||||
}
|
||||
if (!empty($filters['zonename'])) {
|
||||
$this->like('zonename', $filters['zonename'], 'both');
|
||||
if (!empty($filter['zoneid'])) {
|
||||
$this->where('parentzoneid', $filter['zoneid']);
|
||||
}
|
||||
|
||||
return $this->findAll();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user