本文整理汇总了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;
}
示例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);
}
示例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;
}