Ejemplo n.º 1
0
 /**
  *  Function to store custom field
  *
  * @access	public
  * @param   \Illuminate\Http\Request                    $request
  * @param   \Syscover\Pulsar\Models\CustomFieldGroup    $customFieldGroup
  * @param   string                                      $resource
  * @param   integer                                     $objectId
  * @param   string                                      $lang
  * @return  void
  */
 public static function storeCustomFieldResults($request, $customFieldGroup, $resource, $objectId, $lang)
 {
     $customFieldGroup = CustomFieldGroup::find($customFieldGroup);
     $customFields = CustomField::getRecords(['lang_026' => $lang, 'group_id_026' => $customFieldGroup->id_025]);
     $dataTypes = collect(config('pulsar.dataTypes'))->keyBy('id');
     $customFieldResults = [];
     foreach ($customFields as $customField) {
         // if we return an array but the data to be saved is not an array, we will keep as many records containing the array elements
         if (is_array($request->input($customField->name_026 . '_custom')) && $dataTypes[$customField->data_type_id_026]->type != 'array') {
             foreach ($request->input($customField->name_026 . '_custom') as $value) {
                 $customFieldResult = ['object_id_028' => $objectId, 'lang_id_028' => $lang, 'resource_id_028' => $resource, 'field_id_028' => $customField->id_026, 'data_type_type_028' => $dataTypes[$customField->data_type_id_026]->type, 'value_028' => $value];
                 $customFieldResults[] = $customFieldResult;
             }
         } else {
             $customFieldResult = ['object_id_028' => $objectId, 'lang_id_028' => $lang, 'resource_id_028' => $resource, 'field_id_028' => $customField->id_026, 'data_type_type_028' => $dataTypes[$customField->data_type_id_026]->type];
             // if we return an array and the data to be saved is an array, the array will keep like string expression.
             // using insert not access to mutators on Syscover\Pulsar\Models\CustomFieldResult to change the value type of a string to array automatically
             // we have to do manually casting
             if (is_array($request->input($customField->name_026 . '_custom')) && $dataTypes[$customField->data_type_id_026]->type == 'array') {
                 $customFieldResult['value_028'] = implode(',', $request->input($customField->name_026 . '_custom'));
             } else {
                 // get value and record in your field data type, add suffix '_custom' to avoid conflict with other field names
                 if ($dataTypes[$customField->data_type_id_026]->type == 'boolean') {
                     $customFieldResult['value_028'] = $request->has($customField->name_026 . '_custom');
                 } else {
                     $customFieldResult['value_028'] = $request->input($customField->name_026 . '_custom');
                 }
             }
             $customFieldResults[] = $customFieldResult;
         }
     }
     if (count($customFieldResults) > 0) {
         CustomFieldResult::insert($customFieldResults);
     }
 }
Ejemplo n.º 2
0
 public function editCustomRecord($parameters)
 {
     $parameters['editors'] = config('cms.editors');
     $parameters['customFieldGroups'] = CustomFieldGroup::builder()->where('resource_id_025', 'cms-article-family')->get();
     $parameters['data'] = json_decode($parameters['object']->data_351);
     return $parameters;
 }
Ejemplo n.º 3
0
 public function editCustomRecord($parameters)
 {
     $parameters['groups'] = CustomFieldGroup::all();
     $parameters['fieldTypes'] = config('pulsar.fieldTypes');
     $parameters['dataTypes'] = config('pulsar.dataTypes');
     return $parameters;
 }
Ejemplo n.º 4
0
 /**
  * @deprecated
  * @param $args
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public static function getRecords($args)
 {
     $query = CustomFieldGroup::query();
     if (isset($args['resource_id_025'])) {
         $query->where('resource_id_025', $args['resource_id_025']);
     }
     return $query->get();
 }
Ejemplo n.º 5
0
 public function editCustomRecord($parameters)
 {
     $parameters['services'] = Service::where('lang_id_153', $parameters['lang']->id_001)->get();
     $parameters['environments'] = Environment::where('lang_id_150', $parameters['lang']->id_001)->get();
     $parameters['decorations'] = Decoration::where('lang_id_151', $parameters['lang']->id_001)->get();
     $parameters['relationships'] = Relationship::where('lang_id_152', $parameters['lang']->id_001)->get();
     $parameters['publications'] = Publication::all();
     $parameters['restaurantTypes'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('hotels.restaurantTypes'));
     // get attachments elements
     $attachments = AttachmentLibrary::getRecords($this->package, 'hotels-hotel', $parameters['object']->id_170, $parameters['lang']->id_001);
     $parameters['products'] = Product::builder()->where('active_111', true)->where('lang_id_112', $parameters['lang']->id_001)->get();
     // get attachments products with photo list
     $parameters['attachmentsProducts'] = Attachment::builder()->where('lang_id_016', $parameters['lang']->id_001)->where('resource_id_016', 'market-product')->where('family_id_016', config('hotels.idAttachmentsFamily.productList'))->get()->keyBy('object_id_016');
     // merge parameters and attachments array
     $parameters['customFieldGroups'] = CustomFieldGroup::builder()->where('resource_id_025', 'hotels-hotel')->get();
     $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'hotels-hotel']);
     $parameters = array_merge($parameters, $attachments);
     // get hotel products
     $parameters['hotelProducts'] = $parameters['object']->getHotelProducts->keyBy('product_id_177');
     $parameters['hotelProductsIds'] = json_encode($parameters['hotelProducts']->keys()->map(function ($item, $key) {
         return strval($item);
     }));
     return $parameters;
 }
Ejemplo n.º 6
0
 public function editCustomRecord($parameters)
 {
     $parameters['categories'] = Category::where('lang_id_110', $parameters['lang']->id_001)->get();
     $parameters['productTypes'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('market.productTypes'));
     $parameters['priceTypes'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('market.priceTypes'));
     $parameters['productClassTaxes'] = ProductClassTax::builder()->get();
     $parameters['parentsProducts'] = Product::builder()->where('lang_id_112', base_lang()->id_001)->where('id_111', '<>', $parameters['id'])->whereNull('parent_product_id_111')->get();
     $taxRules = TaxRule::builder()->where('country_id_103', config('market.taxCountry'))->where('customer_class_tax_id_106', config('market.taxCustomerClass'))->where('product_class_tax_id_107', $parameters['object']->product_class_tax_id_111)->orderBy('priority_104', 'asc')->get();
     $taxes = TaxRuleLibrary::taxCalculateOverSubtotal($parameters['object']->subtotal_111, $taxRules);
     // ATTENTION! we create custom properties tax_amount_111 and total_111
     $parameters['object']->tax_amount_111 = $taxes->sum('taxAmount');
     $parameters['object']->total_111 = $parameters['object']->subtotal_111 + $parameters['object']->tax_amount_111;
     $attachments = AttachmentLibrary::getRecords($this->package, 'market-product', $parameters['object']->id_111, $parameters['lang']->id_001);
     $parameters['customFieldGroups'] = CustomFieldGroup::builder()->where('resource_id_025', 'market-product')->get();
     $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'market-product']);
     $parameters = array_merge($parameters, $attachments);
     return $parameters;
 }
Ejemplo n.º 7
0
 public function editCustomRecord($parameters)
 {
     // get attachments elements
     $attachments = AttachmentLibrary::getRecords('spas', 'spas-spa', $parameters['object']->id_180, $parameters['lang']->id_001);
     // merge parameters and attachments array
     $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'spas-spa']);
     $parameters['customFieldGroups'] = CustomFieldGroup::builder()->where('resource_id_025', 'spas-spa')->get();
     $parameters['hotels'] = Hotel::builder()->where('active_170', true)->get();
     $parameters = array_merge($parameters, $attachments);
     return $parameters;
 }
Ejemplo n.º 8
0
 public function updateCustomRecord($parameters)
 {
     CustomFieldGroup::where('id_025', $parameters['id'])->update(['resource_id_025' => $this->request->input('resource'), 'name_025' => $this->request->input('name')]);
 }