User Order step1

This commit is contained in:
Kevin Adametz 2020-08-07 16:02:03 +02:00
parent eb55b01b0d
commit a5db985ae8
90 changed files with 6439 additions and 421 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Model;
/**
@ -34,13 +35,15 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightFrom($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightTo($value)
* @mixin \Eloquent
* @property-write mixed $tax
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTaxRate($value)
*/
class ShippingPrice extends Model
{
protected $table = 'shipping_prices';
protected $fillable = [
'shipping_id', 'price', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
'shipping_id', 'price', 'price_comp', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
];
public function shipping()
@ -49,115 +52,65 @@ class ShippingPrice extends Model
}
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));
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
}
public function setPriceCompAttribute($value)
{
$this->attributes['price_comp'] = $value ? Util::reFormatNumber($value) : null;
}
public function setFactorAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['factor'] = null;
} else {
$this->attributes['factor'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['factor'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTaxAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['tax_rate'] = null;
} else {
$this->attributes['tax_rate'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['tax_rate'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTotalFromAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_from'] = null;
} else {
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['total_from'] = $value ? Util::reFormatNumber($value) : null;
}
public function setTotalToAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_to'] = null;
} else {
$this->attributes['total_to'] = floatval(str_replace(',', '.', $value));
}
$this->attributes['total_to'] = $value ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
{
if ($this->attributes['price'] === NULL) {
return $this->attributes['price'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['price'], 2, '.', ',');
}
return number_format($this->attributes['price'], 2, ',', '.');
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
}
public function getFormattedPriceComp()
{
return isset($this->attributes['price_comp']) ? Util::formatNumber($this->attributes['price_comp']) : "";
}
public function getFormattedTaxRate()
{
if ($this->attributes['tax_rate'] === NULL) {
return $this->attributes['tax_rate'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['tax_rate'], 2, '.', ',');
}
return number_format($this->attributes['tax_rate'], 2, ',', '.');
return isset($this->attributes['tax_rate']) ? Util::formatNumber($this->attributes['tax_rate']) : "";
}
public function getFormattedFactor()
{
if ($this->attributes['factor'] === NULL) {
return $this->attributes['factor'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['factor'], 2, '.', ',');
}
return number_format($this->attributes['factor'], 2, ',', '.');
return isset($this->attributes['factor']) ? Util::formatNumber($this->attributes['factor']) : "";
}
public function getFormatTotalFrom()
{
if ($this->attributes['total_from'] === NULL) {
return $this->attributes['total_from'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_from'], 2, '.', ',');
}
return number_format($this->attributes['total_from'], 2, ',', '.');
return isset($this->attributes['total_from']) ? Util::formatNumber($this->attributes['total_from']) : "";
}
public function getFormattedTotalTo()
{
if ($this->attributes['total_to'] === NULL) {
return $this->attributes['total_to'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_to'], 2, '.', ',');
}
return number_format($this->attributes['total_to'], 2, ',', '.');
return isset($this->attributes['total_to']) ? Util::formatNumber($this->attributes['total_to']) : "";
}