/** * Dynamically access route parameters. * * @param string $key * @return mixed */ public function __get($key) { if ($key === 'classTax' || $key === 'class_tax' || $key === 'class_tax_111') { return $this->classTax; } // check if property is mapped if (isset($this->maps[$key])) { return $this->{$this->maps[$key]}; } // call parent method in model return parent::getAttribute($key); }
/** * Dynamically access route parameters. * * @param string $key * @return mixed */ public function __get($key) { // total property if ($key === 'price' || $key === 'price_111') { if (config('market.taxProductDisplayPrices') == TaxRuleLibrary::PRICE_WITHOUT_TAX) { return $this->subtotal_111; } elseif (config('market.taxProductDisplayPrices') == TaxRuleLibrary::PRICE_WITH_TAX) { return $this->total_111; } } // total property if ($key === 'total' || $key === 'total_111') { if ($this->total !== null) { return $this->total; } if ($this->taxAmount !== null) { $this->total = $this->subtotal_111 + $this->taxAmount; return $this->total; } if ($this->taxRules === null) { $this->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', $this->product_class_tax_id_111)->orderBy('priority_104', 'asc')->get(); } $taxes = TaxRuleLibrary::taxCalculateOverSubtotal($this->subtotal_111, $this->taxRules->where('product_class_tax_id_107', $this->product_class_tax_id_111)); $this->taxAmount = $taxes->sum('taxAmount'); $this->total = $this->subtotal_111 + $this->taxAmount; return $this->total; } // taxAmount property if ($key === 'taxAmount' || $key === 'tax_amount' || $key === 'tax_amount_111') { if ($this->taxAmount !== null) { return $this->taxAmount; } else { if ($this->taxRules === null) { $this->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', $this->product_class_tax_id_111)->orderBy('priority_104', 'asc')->get(); } $taxes = TaxRuleLibrary::taxCalculateOverSubtotal($this->subtotal_111, $this->taxRules->where('product_class_tax_id_107', $this->product_class_tax_id_111)); $this->taxAmount = $taxes->sum('taxAmount'); return $this->taxAmount; } } if ($key === 'taxRules' || $key === 'tax_rules' || $key === 'tax_rules_111') { return $this->taxRules; } // check if property is mapped if (isset($this->maps[$key])) { return $this->{$this->maps[$key]}; } // call parent method in model return parent::getAttribute($key); }