Beispiel #1
0
 public function getCity(Request $req)
 {
     $state = State::find($req->id);
     $city = City::where('state_code', $state->code)->get();
     $html = '<option value="" selected>Choose Option</option>';
     foreach ($city as $cities) {
         $html .= '<option value="' . $cities->id . '">' . $cities->name . '</option>';
     }
     echo $html;
 }
 public function cityAutocompleteAction()
 {
     $c = $this->query->get('c');
     $cities = City::where('active', '=', 1)->where('name', '=', $c);
     //
     //        $cities = $this->em->getRepository('PoiskRabotyMainBundle:City')->get(array(
     //            'enabled' => true,
     //            'search_start' => $c,
     //        ));
     $json = array();
     foreach ($cities as $city) {
         $json[] = array('value' => $this->helper->getTranslation($city, 'title'), 'label' => $this->helper->getTranslation($city, 'title'));
     }
     return new JsonResponse($json);
 }
 public function getCity($country = null)
 {
     try {
         $response = [];
         $statusCode = 200;
         //$city = City::all();
         $city = City::where('city_accent', 'like', '%' . $country . '%')->take(10)->get();
         foreach ($city as $c) {
             $response[] = ['id' => $c->id, 'city_accent' => $c->city_accent . ' (' . $c->country_id . ')'];
         }
     } catch (Exception $e) {
         $statusCode = 404;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
 public function locations($state_id, $city_key)
 {
     $city = City::where("estado_id", $state_id)->where("clave", $city_key)->first();
     $locations = Location::where("municipio_id", $city->id)->get();
     return response()->json($locations)->header('Access-Control-Allow-Origin', '*');
 }
Beispiel #5
0
 function result($id)
 {
     $blueprint = Blueprint::with(["questions.options"])->find($id);
     $test = function ($question_type, $inegi_key) {
         if (!$inegi_key) {
             return "-";
         }
         switch ($question_type) {
             case "location-a":
                 $key = substr($inegi_key->text_value, 0, 2);
                 $name = !empty($key) ? $this->states[$key] : "-";
                 break;
             case "location-b":
                 $state_key = substr($inegi_key->text_value, 0, 2);
                 $state_name = !empty($state_key) ? $this->states[$state_key] : "-";
                 $city_key = substr($inegi_key->text_value, 2, 3);
                 $city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
                 $city_name = $city ? $city->nombre : "-";
                 $name = $city_name . ", " . $state_name;
                 break;
             case "location-c":
                 $state_key = substr($inegi_key->text_value, 0, 2);
                 $state_name = !empty((int) $state_key) ? $this->states[$state_key] : "-";
                 $city_key = substr($inegi_key->text_value, 2, 3);
                 $city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
                 $city_name = $city ? $city->nombre : "-";
                 $location_key = substr($inegi_key->text_value, 5, 4);
                 $location = !empty((int) $location_key) ? Location::where("clave", $location_key)->where("municipio_id", $city->id)->first() : null;
                 $location_name = $location ? $location->nombre : "-";
                 $name = $location_name . ", " . $city_name . ", " . $state_name;
                 break;
             default:
                 $name = "-";
                 break;
         }
         return $name;
     };
     if (!$blueprint) {
         die("Este formulario no existe!");
     }
     $data = [];
     $data['blueprint'] = $blueprint;
     $data['title'] = 'Resultados | Tú Evalúas';
     $data['description'] = 'Resultados de cuestionarios en Tú Evalúas';
     $data['body_class'] = 'results';
     $data['test'] = $test;
     return view("frontend.result_survey")->with($data);
 }
Beispiel #6
0
 public static function getCity($id)
 {
     $cities = City::where('state_id', '=', $id)->get(['name', 'id']);
     //echo ($cities);
     return response()->json($cities);
 }
Beispiel #7
0
 private function find_location($question_type, $inegi_key)
 {
     if (!$inegi_key) {
         return "-";
     }
     switch ($question_type) {
         case "location-a":
             $key = substr($inegi_key->text_value, 0, 2);
             $name = !empty($key) ? $this->states[$key] : "-";
             break;
         case "location-b":
             $state_key = substr($inegi_key->text_value, 0, 2);
             $state_name = !empty($state_key) ? $this->states[$state_key] : "-";
             $city_key = substr($inegi_key->text_value, 2, 3);
             $city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
             $city_name = $city ? $city->nombre : "-";
             $name = $city_name . ", " . $state_name;
             break;
         case "location-c":
             $state_key = substr($inegi_key->text_value, 0, 2);
             $state_name = !empty($state_key) ? $this->states[$state_key] : "-";
             $city_key = substr($inegi_key->text_value, 2, 3);
             $city = !empty($city_key) ? City::where("clave", $city_key)->where("estado_id", (int) $state_key)->first() : null;
             $city_name = $city ? $city->nombre : "-";
             $location_key = substr($inegi_key->text_value, 5, 4);
             $location = !empty($location_key) ? Location::where("clave", $location_key)->where("municipio_id", $city->id)->first() : null;
             $location_name = $location ? $location->nombre : "-";
             $name = $location_name . ", " . $city_name . ", " . $state_name;
             break;
         default:
             $name = "-";
             break;
     }
     return $name;
 }
 public function getTakeCity()
 {
     $state_id = \Request::input('province_id');
     $emptyData = [];
     if (empty($state_id)) {
         return $emptyData;
     }
     $queryCity = Md\City::where('state_id', '=', $state_id);
     $sites = $queryCity->lists('name', 'city_id');
     return $sites;
 }
  public function getCity (Request $request) 
  {
    $province = $request->input('province');

    $cities = City::where('province_code', '=', $province)

      ->where('active', '=', 1)

      ->get();

    $html = $this->cityList($cities);

    return $this->successResponse('res', $html);
  
  }