Example #1
0
 public function storeCustomRecord($parameters)
 {
     if (!$this->request->has('id')) {
         // create new hotel
         $hotel = Hotel::create(['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'), 'password_170' => Hash::make($this->request->input('password')), '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')]);
         $id = $hotel->id_170;
         $idLang = null;
         // publications
         if (is_array($this->request->input('published'))) {
             $hotel->getPublications()->sync($this->request->input('published'));
         }
         // services
         if (is_array($this->request->input('services'))) {
             $hotel->getServices()->sync($this->request->input('services'));
         }
     } else {
         // create hotel language
         $id = $this->request->input('id');
         $idLang = $id;
     }
     Hotel::where('id_170', $id)->update(['data_lang_170' => Hotel::addLangDataRecord($this->request->input('lang'), $idLang)]);
     HotelLang::create(['id_171' => $id, 'lang_id_171' => $this->request->input('lang'), '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
     $hotelProducts = [];
     $products = json_decode($this->request->input('products'));
     foreach ($products as $product) {
         $hotelProducts[] = ['hotel_id_177' => $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 attachments
     $attachments = json_decode($this->request->input('attachments'));
     AttachmentLibrary::storeAttachments($attachments, $this->package, 'hotels-hotel', $id, $this->request->input('lang'));
     // set custom fields
     if (!empty($this->request->input('customFieldGroup'))) {
         CustomFieldResultLibrary::storeCustomFieldResults($this->request, $this->request->input('customFieldGroup'), 'hotels-hotel', $id, $this->request->input('lang'));
     }
 }