belongsTo('App\Models\Shipping', 'shipping_id'); } public function _format_number($value){ return preg_replace("/[^0-9,]/", "", $value); } public function setPriceAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['price'] = floatval(str_replace(',', '.', $value)); } public function setFactorAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['factor'] = floatval(str_replace(',', '.', $value)); } public function setTaxAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['tax'] = floatval(str_replace(',', '.', $value)); } public function setPriceOldAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['price_old'] = floatval(str_replace(',', '.', $value)); } public function setTotalFromAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['total_from'] = floatval(str_replace(',', '.', $value)); } public function setTotalToAttribute( $value ) { $value = $this->_format_number($value); $this->attributes['total_to'] = floatval(str_replace(',', '.', $value)); } public function getFormattedPrice() { if(\App::getLocale() == "en"){ return number_format($this->attributes['price'], 2, '.', ','); } return number_format($this->attributes['price'], 2, ',', '.'); } public function getFormattedTax() { if(\App::getLocale() == "en"){ return number_format($this->attributes['tax'], 2, '.', ','); } return number_format($this->attributes['tax'], 2, ',', '.'); } public function getFormattedFactor() { if(\App::getLocale() == "en"){ return number_format($this->attributes['factor'], 2, '.', ','); } return number_format($this->attributes['factor'], 2, ',', '.'); } public function getFormatTotalFrom() { if(\App::getLocale() == "en"){ return number_format($this->attributes['total_from'], 2, '.', ','); } return number_format($this->attributes['total_from'], 2, ',', '.'); } public function getFormattedTotalTo() { if(\App::getLocale() == "en"){ return number_format($this->attributes['total_to'], 2, '.', ','); } return number_format($this->attributes['total_to'], 2, ',', '.'); } }