case 'countrys': $htl = new CountryController(); $htl->CityList($_GET['id']); break; default: echo json_encode(['err' => 1, 'message' => 'invalid action']); } } elseif (isset($_GET['p1']) && $_GET['p1'] != 'index') { switch (strtolower($_GET['p1'])) { case 'hotels': //list all hotels //list all hotels case 'hotel': $htl = new HotelController(); if (!isset($_GET['page'], $_GET['per_page'])) { $htl->Hotels(); } else { $htl->Hotels($_GET['page'], $_GET['per_page']); } break; case 'countrys': //list all country //list all country case 'countries': case 'country': $ctry = new CountryController(); $ctry->Countries(); break; default: echo json_encode(['err' => 1, 'message' => 'invalid action']); }