Example #1
0
 public static function getRecords($parameters)
 {
     $query = HotelProduct::builder();
     if (isset($parameters['hotel_id_177'])) {
         $query->where('hotel_id_177', $parameters['hotel_id_177']);
     }
     if (isset($parameters['lang_id_177'])) {
         $query->where('lang_id_177', $parameters['lang_id_177']);
     }
     return $query->get();
 }
Example #2
0
 public function updateCustomRecord($parameters)
 {
     $hotel = ['field_group_id_170' => $this->request->has('customFieldGroup') ? $this->request->input('customFieldGroup') : null, 'name_170' => $this->request->input('name'), 'slug_170' => $this->request->input('slug'), 'web_170' => $this->request->input('web'), 'web_url_170' => $this->request->input('webUrl'), 'contact_170' => $this->request->input('contact'), 'email_170' => $this->request->input('email'), 'booking_email_170' => $this->request->input('bookingEmail'), 'phone_170' => $this->request->input('phone'), 'mobile_170' => $this->request->input('mobile'), 'fax_170' => $this->request->input('fax'), 'environment_170' => $this->request->has('environment') ? $this->request->input('environment') : null, 'decoration_170' => $this->request->has('decoration') ? $this->request->input('decoration') : null, 'relationship_170' => $this->request->has('relationship') ? $this->request->input('relationship') : null, 'n_rooms_170' => $this->request->input('nRooms'), 'n_places_170' => $this->request->input('nPlaces'), 'n_events_rooms_170' => $this->request->input('nEventsRooms'), 'n_events_rooms_places_170' => $this->request->input('nEventsRoomsPlaces'), 'user_170' => $this->request->input('user'), 'active_170' => $this->request->has('active'), 'country_id_170' => $this->request->input('country'), 'territorial_area_1_id_170' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_170' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_170' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_170' => $this->request->has('cp') ? $this->request->input('cp') : null, 'locality_170' => $this->request->input('locality'), 'address_170' => $this->request->input('address'), 'latitude_170' => str_replace(',', '', $this->request->input('latitude')), 'longitude_170' => str_replace(',', '', $this->request->input('longitude')), 'booking_url_170' => $this->request->input('bookingUrl'), 'country_chef_restaurant_170' => $this->request->has('countryChefRestaurant'), 'country_chef_url_170' => $this->request->input('countryChefUrl'), 'restaurant_name_170' => $this->request->input('restaurantName'), 'restaurant_type_id_170' => $this->request->has('restaurantType') ? $this->request->input('restaurantType') : null, 'restaurant_terrace_170' => $this->request->has('restaurantTerrace'), 'billing_name_170' => $this->request->input('billingName'), 'billing_surname_170' => $this->request->input('billingSurname'), 'billing_company_name_170' => $this->request->input('billingCompanyName'), 'billing_tin_170' => $this->request->input('billingTin'), 'billing_country_id_170' => $this->request->has('billingCountry') ? $this->request->input('billingCountry') : null, 'billing_territorial_area_1_id_170' => $this->request->has('billingTerritorialArea1') ? $this->request->input('billingTerritorialArea1') : null, 'billing_territorial_area_2_id_170' => $this->request->has('billingTerritorialArea2') ? $this->request->input('billingTerritorialArea2') : null, 'billing_territorial_area_3_id_170' => $this->request->has('billingTerritorialArea3') ? $this->request->input('billingTerritorialArea3') : null, 'billing_cp_170' => $this->request->has('billingCp') ? $this->request->input('billingCp') : null, 'billing_locality_170' => $this->request->input('billingLocality'), 'billing_address_170' => $this->request->input('billingAddress'), 'billing_phone_170' => $this->request->input('billingPhone'), 'billing_email_170' => $this->request->input('billingEmail'), 'billing_iban_country_170' => $this->request->input('billingIbanCountry'), 'billing_iban_check_digits_170' => $this->request->input('billingIbanCheckDigits'), 'billing_iban_basic_bank_account_number_170' => $this->request->input('billingIbanBasicBankAccountNumber'), 'billing_bic_170' => $this->request->input('billingBic')];
     if ($parameters['specialRules']['emailRule']) {
         $hotel['email_170'] = $this->request->input('email');
     }
     if ($parameters['specialRules']['userRule']) {
         $hotel['user_170'] = $this->request->input('user');
     }
     if (!$parameters['specialRules']['passRule']) {
         $hotel['password_170'] = Hash::make($this->request->input('password'));
     }
     Hotel::where('id_170', $parameters['id'])->update($hotel);
     $hotel = Hotel::find($parameters['id']);
     // publications
     if (is_array($this->request->input('published'))) {
         $hotel->getPublications()->sync($this->request->input('published'));
     } else {
         $hotel->getPublications()->detach();
     }
     // services
     if (is_array($this->request->input('services'))) {
         $hotel->getServices()->sync($this->request->input('services'));
     } else {
         $hotel->getServices()->detach();
     }
     HotelLang::where('id_171', $parameters['id'])->where('lang_id_171', $this->request->input('lang'))->update(['cuisine_171' => $this->request->has('cuisine') ? $this->request->input('cuisine') : null, 'special_dish_171' => $this->request->has('specialDish') ? $this->request->input('specialDish') : null, 'indications_171' => $this->request->has('indications') ? $this->request->input('indications') : null, 'interest_points_171' => $this->request->has('interestPoints') ? $this->request->input('interestPoints') : null, 'environment_description_171' => $this->request->has('environmentDescription') ? $this->request->input('environmentDescription') : null, 'construction_171' => $this->request->has('construction') ? $this->request->input('construction') : null, 'activities_171' => $this->request->has('activities') ? $this->request->input('activities') : null, 'description_title_171' => $this->request->has('descriptionTitle') ? $this->request->input('descriptionTitle') : null, 'description_171' => $this->request->has('description') ? $this->request->input('description') : null]);
     // set hotel products
     HotelProduct::where('hotel_id_177', $parameters['id'])->where('lang_id_177', $this->request->input('lang'))->delete();
     $hotelProducts = [];
     $products = json_decode($this->request->input('products'));
     foreach ($products as $product) {
         $hotelProducts[] = ['hotel_id_177' => $parameters['id'], 'product_id_177' => $product, 'lang_id_177' => $this->request->input('lang'), 'description_177' => $this->request->input('d' . $product)];
     }
     if (count($hotelProducts) > 0) {
         HotelProduct::insert($hotelProducts);
     }
     // set custom fields
     if (!empty($this->request->input('customFieldGroup'))) {
         CustomFieldResultLibrary::deleteCustomFieldResults('hotels-hotel', $parameters['id'], $this->request->input('lang'));
         CustomFieldResultLibrary::storeCustomFieldResults($this->request, $this->request->input('customFieldGroup'), 'hotels-hotel', $parameters['id'], $this->request->input('lang'));
     } else {
         CustomFieldResultLibrary::deleteCustomFieldResults('hotels-hotel', $parameters['id'], $this->request->input('lang'));
     }
 }