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; }
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; }
public function editCustomRecord($parameters) { $parameters['products'] = Product::builder()->where('lang_id_112', base_lang()->id_001)->get(); return $parameters; }
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(); }
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; }