本文整理汇总了PHP中app\models\City::where方法的典型用法代码示例。如果您正苦于以下问题:PHP City::where方法的具体用法?PHP City::where怎么用?PHP City::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\City
的用法示例。
在下文中一共展示了City::where方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCity
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;
}
示例2: cityAutocompleteAction
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);
}
示例3: getCity
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);
}
}
示例4: locations
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', '*');
}
示例5: result
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);
}
示例6: getCity
public static function getCity($id)
{
$cities = City::where('state_id', '=', $id)->get(['name', 'id']);
//echo ($cities);
return response()->json($cities);
}
示例7: find_location
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;
}
示例8: getTakeCity
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;
}
示例9: getCity
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);
}