Exemplo n.º 1
0
 public function editCustomRecord($parameters)
 {
     $parameters['campaigns'] = Campaign::builder()->where('active_221', true)->get();
     $parameters['products'] = Product::builder()->where('lang_id_112', base_lang()->id_001)->get();
     $parameters['places'] = Place::builder()->get();
     $productPrefixes = ProductPrefix::all();
     $parameters['products']->map(function ($item, $key) use($productPrefixes) {
         // set prefix products
         $productPrefix = $productPrefixes->where('product_id_222', $item->id_111)->first();
         if ($productPrefix == null) {
             return $item->prefix_222 = null;
         }
         return $item->prefix_222 = $productPrefixes->where('product_id_222', $item->id_111)->first()->prefix_222;
     });
     $response = FacturaDirecta::getInvoice($parameters['object']->invoice_id_226);
     $collection = collect();
     // check that response does not contain httpStatus 404
     if (!isset($response['httpStatus'])) {
         // set id like integer, to compare in select
         $response['id'] = (int) $response['id'];
         $parameters['invoices'] = $collection->push(Miscellaneous::arrayToObject($response));
     }
     // objects from place
     if (isset($parameters['object']->place_id_226)) {
         $result = collect(config('booking.models'))->where('id', $parameters['object']->place_id_226);
         if (count($result) === 0) {
             return response()->json(['status' => 'error', 'code' => 404, 'message' => 'Records not found']);
         }
         // model constructor
         $model = App::make($result->first()->model);
         // use sofa to get lang from lang table of object query
         $parameters['objects'] = $model->builder()->where('lang_id', base_lang()->id_001)->get();
         $parameters['objectName'] = trans_choice($result->first()->name, 1);
     }
     return $parameters;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public function editCustomRecord($parameters)
 {
     $parameters['products'] = Product::builder()->where('lang_id_112', base_lang()->id_001)->get();
     return $parameters;
 }
Exemplo n.º 4
0
 public static function getTranslationRecord($parameters)
 {
     return Product::builder()->where('lang_id_112', $parameters['lang'])->where('lang_id_112', $parameters['lang'])->where('id_111', $parameters['id'])->first();
 }
Exemplo n.º 5
0
 public function updateCustomRecord($parameters)
 {
     // update product
     Product::where('id_111', $parameters['id'])->update(['field_group_id_111' => $this->request->has('customFieldGroup') ? $this->request->input('customFieldGroup') : null, 'type_id_111' => $this->request->input('productType'), 'parent_product_id_111' => $this->request->has('parentProduct') ? $this->request->input('parentProduct') : null, 'weight_111' => $this->request->has('weight') ? $this->request->input('weight') : 0, 'active_111' => $this->request->has('active'), 'sorting_111' => $this->request->has('sorting') ? $this->request->input('sorting') : null, 'price_type_id_111' => $this->request->input('priceType'), 'subtotal_111' => $this->getSubtotalOverTotal(), 'product_class_tax_id_111' => $this->request->has('productClassTax') ? $this->request->input('productClassTax') : null]);
     ProductLang::where('id_112', $parameters['id'])->where('lang_id_112', $this->request->input('lang'))->update(['name_112' => $this->request->input('name'), 'slug_112' => $this->request->input('slug'), 'description_112' => $this->request->input('description')]);
     $product = Product::where('id_111', $parameters['id'])->first();
     // categories
     if (is_array($this->request->input('categories'))) {
         $product->getCategories()->sync($this->request->input('categories'));
     } else {
         $product->getCategories()->detach();
     }
     // set custom fields
     if (!empty($this->request->input('customFieldGroup'))) {
         CustomFieldResultLibrary::deleteCustomFieldResults('market-product', $parameters['id'], $this->request->input('lang'));
         CustomFieldResultLibrary::storeCustomFieldResults($this->request, $this->request->input('customFieldGroup'), 'market-product', $parameters['id'], $this->request->input('lang'));
     }
 }