当前位置: 首页>>代码示例>>PHP>>正文


PHP models\City类代码示例

本文整理汇总了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());
 }
开发者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


注:本文中的app\models\City类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。