本文整理汇总了PHP中app\models\City类的典型用法代码示例。如果您正苦于以下问题:PHP City类的具体用法?PHP City怎么用?PHP City使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了City类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:EHER,项目名称:chegamos,代码行数:28,代码来源:LocationControllerTest.php
示例2: saveNewCityRecord
public function saveNewCityRecord()
{
$city = new City();
$city['city'] = Input::get('txtCity');
if ($city->save()) {
return 1;
} else {
return 0;
}
}
开发者ID:jhunel2389,项目名称:hp-sis,代码行数:10,代码来源:FileMaintenanceController.php
示例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;
}
开发者ID:carono,项目名称:yii2-components,代码行数:10,代码来源:CityController.php
示例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]);
}
开发者ID:unix-admin,项目名称:profitday,代码行数:11,代码来源:SiteController.php
示例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);
}
}
开发者ID:EHER,项目名称:chegamos,代码行数:14,代码来源:Location.php
示例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;
}
}
开发者ID:engmohamedamer,项目名称:gotest,代码行数:25,代码来源:ShopcartController.php
示例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'));
}
开发者ID:rodiaa,项目名称:trpo,代码行数:13,代码来源:PlaceController.php
示例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());
}
开发者ID:EHER,项目名称:chegamos,代码行数:7,代码来源:CityTest.php
示例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']);
}
开发者ID:ruslankus,项目名称:lavarel-lessons,代码行数:13,代码来源:CitySeeder.php
示例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]);
}
}
开发者ID:EduSec,项目名称:EduSec,代码行数:8,代码来源:DependentController.php
示例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;
}
开发者ID:islamham,项目名称:125ent,代码行数:9,代码来源:SiteController.php
示例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'));
}
开发者ID:vuongabc92,项目名称:ot,代码行数:17,代码来源:HomeController.php
示例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();
}
开发者ID:mauhftw,项目名称:mizustats,代码行数:10,代码来源:MqttUserHelper.php
示例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;
}
开发者ID:khakanali,项目名称:OpenMAll,代码行数:10,代码来源:AjaxController.php
示例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);
}
开发者ID:frankpaul142,项目名称:chaide,代码行数:10,代码来源:LocaleController.php
示例16: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'region_id' => $this->region_id, 'region_global_id' => $this->region_global_id, 'gmt' => $this->gmt, 'sort_id' => $this->sort_id, 'old_region_id' => $this->old_region_id, 'is_deleted' => $this->is_deleted, 'is_published' => $this->is_published, 'timezone' => $this->timezone]);
$query->andFilterWhere(['like', 'id_1c', $this->id_1c])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'region_1c', $this->region_1c])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'title_1c', $this->title_1c])->andFilterWhere(['like', 'geoip_city', $this->geoip_city])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'alternative_path', $this->alternative_path])->andFilterWhere(['like', 'old_path', $this->old_path])->andFilterWhere(['like', 'service_center', $this->service_center])->andFilterWhere(['like', 'manufacturer_service_center', $this->manufacturer_service_center])->andFilterWhere(['like', 'yandex_confirm_code', $this->yandex_confirm_code])->andFilterWhere(['like', 'yandex_confirm_code_tp', $this->yandex_confirm_code_tp])->andFilterWhere(['like', 'yandex_confirm_code_bazar', $this->yandex_confirm_code_bazar]);
return $dataProvider;
}
开发者ID:Konsul117,项目名称:phonebook,代码行数:18,代码来源:CitySearch.php
示例17: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
开发者ID:tejrajs,项目名称:yii2RestAPI,代码行数:18,代码来源:CitySearch.php
示例18: allCity
public function allCity()
{
$response = array();
$infos = City::all();
if (!empty($infos)) {
foreach ($infos as $info) {
$response[] = array("info_id" => $info['id'], "data_description" => $info['city']);
}
}
return $response;
}
开发者ID:jhunel2389,项目名称:hp-sis,代码行数:11,代码来源:GlobalController.php
示例19: actionEmp_p_city
public function actionEmp_p_city($id)
{
$rows = \app\models\City::find()->where(['city_state_id' => $id, 'is_status' => 0])->all();
echo "<option value=''>---Select City---</option>";
if (count($rows) > 0) {
foreach ($rows as $row) {
echo "<option value='{$row->city_id}'>{$row->city_name}</option>";
}
} else {
echo "";
}
}
开发者ID:aoopvn,项目名称:EduSec4.0.0,代码行数:12,代码来源:DependentController.php
示例20: actionFillTeams
public function actionFillTeams()
{
foreach ($this->arrOfTeams as $team => $city) {
$model = new Khlteams();
$model->name = $team;
$city_id = City::find()->where("name like('" . $city . "')")->one()->id;
if (!$city_id) {
$city_id = 1513;
}
$model->city_id = $city_id;
$model->save(false);
}
}
开发者ID:roman1970,项目名称:lis,代码行数:13,代码来源:KhlController.php
注:本文中的app\models\City类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论