當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Countries::where方法代碼示例

本文整理匯總了PHP中Countries::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Countries::where方法的具體用法?PHP Countries::where怎麽用?PHP Countries::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Countries的用法示例。


在下文中一共展示了Countries::where方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCountry

 public function getCountry($id)
 {
     $country = Countries::where('region_id', '=', $id)->get();
     $html = '<option></option>';
     foreach ($country as $c) {
         $html .= "<option value='" . $c->id . "'>" . $c->name . "</option>";
     }
     echo $html;
 }
開發者ID:andrinda,項目名稱:myhotel,代碼行數:9,代碼來源:GuestController.php

示例2: getIndex

 public function getIndex()
 {
     $hotel = Hotel::find(1);
     $regions = Regions::all();
     $country = Countries::where('region_id', '=', $hotel->city->province->country->region->id)->get();
     $province = Provinces::where('country_id', '=', $hotel->city->province->country->id)->get();
     $city = Cities::where('province_id', '=', $hotel->city->province->id)->get();
     $options = array('hotel' => $hotel, 'regions' => $regions, 'country' => $country, 'province' => $province, 'city' => $city);
     return View::make('home/dashboard', array())->nest('content', 'hotel/profile', $options);
 }
開發者ID:andrinda,項目名稱:myhotel,代碼行數:10,代碼來源:HotelController.php

示例3: loadAddressAttributes

 /**
  * Add country id to attributes array
  *
  * @param  array $attributes
  * @return array $attributes
  * @throws FailedValidationException
  */
 public function loadAddressAttributes(array $attributes)
 {
     // return if no country given
     if (!isset($attributes['country'])) {
         return $attributes;
     }
     // find country
     $country = \Countries::where('iso_3166_2', $attributes['country'])->orWhere('iso_3166_3', $attributes['country'])->first();
     // unset country from attributes array
     unset($attributes['country']);
     // add country_id to attributes array
     if (is_object($country) && isset($country->id)) {
         $attributes['country_id'] = $country->id;
     }
     // run validation
     $validator = $this->validateAddress($attributes);
     if ($validator->fails()) {
         throw new FailedValidationException('Validator failed for: ' . implode(', ', $attributes));
     }
     // return attributes array with country_id key/value pair
     return $attributes;
 }
開發者ID:AlexanderPoellmann,項目名稱:laravel-addresses,代碼行數:29,代碼來源:HasAddresses.php


注:本文中的Countries::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。