本文整理汇总了PHP中app\models\City类的典型用法代码示例。如果您正苦于以下问题:PHP City类的具体用法?PHP City怎么用?PHP City使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了City类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldUpdateCurrentLocation
public function testShouldUpdateCurrentLocation()
{
$currentLocation = null;
$latitude = -23.48033;
$longitude = -46.63459;
$city = new City();
$city->setName("São Paulo");
$city->setState("SP");
$address = new Address();
$address->setCity($city);
$address->setStreet("Rua Funchal");
$address->setDistrict("Vila Olímpia");
$api = $this->getMock("ApontadorApi", array("revgeocode"));
$api->expects($this->once())->method("revgeocode")->with($latitude, $longitude)->will($this->returnValue($address));
$locationController = new LocationController();
$locationController->setApi($api);
$locationController->disableSession();
$locationController->update($latitude, $longitude);
$current = $locationController->current();
$currentLocation = new Location($current['location']);
$this->assertNotNull($currentLocation);
$this->assertSame("SP", $currentLocation->getAddress()->getCity()->getState());
$this->assertSame("São Paulo", $currentLocation->getAddress()->getCity()->getName());
$this->assertSame("Vila Olímpia", $currentLocation->getAddress()->getDistrict());
$this->assertSame("Rua Funchal", $currentLocation->getAddress()->getStreet());
$this->assertSame($latitude, $currentLocation->getPoint()->getLat());
$this->assertSame($longitude, $currentLocation->getPoint()->getLng());
}
示例2: saveNewCityRecord
public function saveNewCityRecord()
{
$city = new City();
$city['city'] = Input::get('txtCity');
if ($city->save()) {
return 1;
} else {
return 0;
}
}
示例3: createCity
public function createCity($name, $attr = [])
{
if (!($model = $this->findCity($name))) {
$model = new City();
$model->name = $name;
$model->setAttributes($attr);
$model->save(false);
}
return $model;
}
示例4: actionCity
public function actionCity()
{
$model = new City();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
// form inputs are valid, do something here
return;
}
}
return $this->render('city', ['model' => $model]);
}
示例5: load
public function load()
{
$this->populate(unserialize(Session::read('location')));
$lat = $this->point->getLat();
$lng = $this->point->getLng();
if (empty($lat) || empty($lng)) {
$city = new City();
$city->setName("São Paulo");
$city->setState("SP");
$this->point->setLat(-23.48033);
$this->point->setLng(-46.63459);
$this->address->setCity($city);
}
}
示例6: actionDeliveryCost
public function actionDeliveryCost($code)
{
//check the api for the returned data
//check country
$city = City::find()->where('Name="' . $code . '"')->one();
//var_dump($city);
if ($city->CountryCode == 'EGY') {
//calculate weight
$sum = 0;
foreach (Shopcart::goods() as $good) {
$sum += $good->item->product_weight;
}
// return "the new cost--".$city->Name .$city->CountryCode;
//$city->CountryCode;
$cost = $this->GetCost($city->Name, $sum);
if ($cost == '' or $cost == 0) {
return Setting::get('deliver_cost');
} else {
return $cost;
}
} else {
return Setting::get('deliver_cost');
//.'-99'. $city->CountryCode;
}
}
示例7: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$place = Place::with(['city', 'category'])->whereId($id)->first();
$categories = Category::all();
$cities = City::all();
return view('client.placeinfo', compact('place', 'categories', 'cities'));
}
示例8: testSetGetName
public function testSetGetName()
{
$this->object->setName('city');
$this->assertEquals('city', $this->object->getName());
$this->object->setName('City');
$this->assertEquals('City', $this->object->getName());
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('Cities')->delete();
City::create(['id' => 1, 'city_name' => 'Vilnius']);
City::create(['id' => 2, 'city_name' => 'Kaunas']);
City::create(['id' => 3, 'city_name' => 'Klaipeda']);
City::create(['id' => 4, 'city_name' => 'Kita']);
}
示例10: actionGetorgcity
public function actionGetorgcity($id)
{
$rows = \app\models\City::find()->where(['state_id' => $id, 'is_status' => 0])->ALL();
echo Html::tag('option', Html::encode(Yii::t('app', '--- Select City ---')), ['value' => '']);
foreach ($rows as $row) {
echo Html::tag('option', Html::encode($row->city_name), ['value' => $row->city_id]);
}
}
示例11: actionGetRegionCities
public function actionGetRegionCities($region_id)
{
$cities = \app\models\City::find()->where(['region_id' => $region_id])->all();
$content = '';
foreach ($cities as $city) {
$content .= '<option value="' . $city->id . '">' . $city->title . '</option>';
}
return $content;
}
示例12: selectLocation
/**
* @todo Save location by session
*
* @param \Illuminate\Http\Request $request
* @param int $id City id
*
* @return Redirect
*/
public function selectLocation($id)
{
$id = (int) $id;
if (!is_null(City::find($id))) {
Session::put(_const('SESSION_LOCATION'), $id);
Session::save();
}
return redirect(route('front_home'));
}
示例13: addAcl
public static function addAcl($data)
{
$city = City::with('state')->where('id', '=', $data['city'])->first();
$acl = new Acl();
$acl->dni = $data['dni'];
$acl->topic = $city->state->name . '/' . $city->name . '/water/' . $acl->dni;
//Definir Mendoza/water/dni
$acl->rw = 1;
$acl->save();
}
示例14: 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;
}
示例15: actionLocales
public function actionLocales()
{
$model = City::findOne($_POST['id']);
$aux = array();
foreach ($model->locales as $k => $locale) {
$aux[$k]['id'] = $locale->id;
$aux[$k]['address'] = $locale->address;
}
echo json_encode($aux);
}