Beispiel #1
0
 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;
 }
Beispiel #2
0
 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);
 }
 /**
  * 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;
 }