Пример #1
0
 public function storeCustomRecord($parameters)
 {
     if (!$this->request->has('id')) {
         // create new winery
         $winery = Winery::create(['field_group_id_190' => $this->request->has('customFieldGroup') ? $this->request->input('customFieldGroup') : null, 'hotel_id_190' => $this->request->has('hotel') ? $this->request->input('hotel') : null, 'name_190' => $this->request->input('name'), 'slug_190' => $this->request->input('slug'), 'web_190' => $this->request->input('web'), 'web_url_190' => $this->request->input('webUrl'), 'contact_190' => $this->request->input('contact'), 'email_190' => $this->request->input('email'), 'phone_190' => $this->request->input('phone'), 'mobile_190' => $this->request->input('mobile'), 'fax_190' => $this->request->input('fax'), 'active_190' => $this->request->has('active'), 'country_id_190' => $this->request->input('country'), 'territorial_area_1_id_190' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_190' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_190' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_190' => $this->request->input('cp'), 'locality_190' => $this->request->input('locality'), 'address_190' => $this->request->input('address'), 'latitude_190' => str_replace(',', '', $this->request->input('latitude')), 'longitude_190' => str_replace(',', '', $this->request->input('longitude'))]);
         $id = $winery->id_190;
         $idLang = null;
     } else {
         // create winery language
         $id = $this->request->input('id');
         $idLang = $id;
     }
     Winery::where('id_190', $id)->update(['data_lang_190' => Winery::addLangDataRecord($this->request->input('lang'), $idLang)]);
     WineryLang::create(['id_191' => $id, 'lang_id_191' => $this->request->input('lang'), 'description_title_191' => $this->request->has('descriptionTitle') ? $this->request->input('descriptionTitle') : null, 'description_191' => $this->request->has('description') ? $this->request->input('description') : null, 'activity_191' => $this->request->has('activity') ? $this->request->input('activity') : null]);
     // set attachments
     $attachments = json_decode($this->request->input('attachments'));
     AttachmentLibrary::storeAttachments($attachments, $this->package, 'wineries-winery', $id, $this->request->input('lang'));
     // set custom fields
     if (!empty($this->request->input('customFieldGroup'))) {
         CustomFieldResultLibrary::storeCustomFieldResults($this->request, $this->request->input('customFieldGroup'), 'wineries-winery', $id, $this->request->input('lang'));
     }
 }