public function updateCustomRecord($parameters) { // get object to update data and data_lang field $customField = CustomField::find($this->request->input('id')); // get values $data = json_decode($customField->data_026, true); // set values $data['labels'][$this->request->input('lang')] = $this->request->input('label'); CustomField::where('id_026', $parameters['id'])->update(['group_id_026' => $this->request->input('group'), 'name_026' => $this->request->input('name'), 'field_type_id_026' => $this->request->input('fieldType'), 'field_type_name_026' => collect(config('pulsar.fieldTypes'))->keyBy('id')[$this->request->input('fieldType')]->name, 'data_type_id_026' => $this->request->input('dataType'), 'data_type_name_026' => collect(config('pulsar.dataTypes'))->keyBy('id')[$this->request->input('dataType')]->name, 'required_026' => $this->request->has('required'), 'sorting_026' => empty($this->request->input('sorting')) ? null : $this->request->input('sorting'), 'max_length_026' => empty($this->request->input('maxLength')) ? null : $this->request->input('maxLength'), 'pattern_026' => empty($this->request->input('pattern')) ? null : $this->request->input('pattern'), 'label_size_026' => empty($this->request->input('labelSize')) ? null : $this->request->input('labelSize'), 'field_size_026' => empty($this->request->input('fieldSize')) ? null : $this->request->input('fieldSize'), 'data_026' => json_encode($data)]); }
public static function deleteTranslationRecord($parameters, $deleteLangDataRecord = true) { $customField = CustomField::find($parameters['id']); // get values $data = collect(json_decode($customField->data_026, true)['labels']); unset($data[$parameters['lang']]); CustomField::where('id_026', $parameters['id'])->update(['data_026' => json_encode(['labels' => $data])]); // set values on data_lang_026 CustomField::deleteLangDataRecord($parameters); }