¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -13,20 +13,24 @@ class TaxRate extends Model
{
use Translatable, SoftDeletes;
/**
* The attributes that are translatable.
*
* @var array
*/
public $translatedAttributes = ['name'];
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = ['translations'];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['country', 'state', 'city', 'zip', 'rate', 'position'];
/**
* The attributes that should be mutated to dates.
*
@@ -34,12 +38,6 @@ class TaxRate extends Model
*/
protected $dates = ['start_date', 'end_date', 'deleted_at'];
/**
* The attributes that are translatable.
*
* @var array
*/
public $translatedAttributes = ['name'];
public function orders()
{
@@ -49,6 +47,7 @@ class TaxRate extends Model
->withPivot('amount');
}
public function scopeFindByAddress($query, $address)
{
$address = $this->mergeDefaultAddress($address);
@@ -66,11 +65,69 @@ class TaxRate extends Model
->orderBy('position');
}
public function getCountryAttribute($country)
{
return $country === '*' ? null : $country;
}
public function setCountryAttribute($country)
{
$this->attributes['country'] = $country ?: '*';
}
public function getStateAttribute($state)
{
return $state === '*' ? null : $state;
}
public function setStateAttribute($state)
{
$this->attributes['state'] = $state ?: '*';
}
public function getCityAttribute($city)
{
return $city === '*' ? null : $city;
}
public function setCityAttribute($city)
{
$this->attributes['city'] = $city ?: '*';
}
public function getZipAttribute($zip)
{
return $zip === '*' ? null : $zip;
}
public function setZipAttribute($zip)
{
$this->attributes['zip'] = $zip ?: '*';
}
public function getTotalAttribute($total)
{
return Money::inDefaultCurrency($total);
}
private function mergeDefaultAddress($address)
{
return $address += ['country' => null, 'state' => null, 'city' => null, 'zip' => null];
$address += ['country' => null, 'state' => null, 'city' => null, 'zip' => null];
return $address;
}
private function rawOrderClause()
{
return "(
@@ -80,49 +137,4 @@ class TaxRate extends Model
CASE WHEN zip = ? THEN 1 ELSE 0 END
) DESC";
}
public function getCountryAttribute($country)
{
return $country === '*' ? null : $country;
}
public function setCountryAttribute($country)
{
$this->attributes['country'] = $country ?: '*';
}
public function getStateAttribute($state)
{
return $state === '*' ? null : $state;
}
public function setStateAttribute($state)
{
$this->attributes['state'] = $state ?: '*';
}
public function getCityAttribute($city)
{
return $city === '*' ? null : $city;
}
public function setCityAttribute($city)
{
$this->attributes['city'] = $city ?: '*';
}
public function getZipAttribute($zip)
{
return $zip === '*' ? null : $zip;
}
public function setZipAttribute($zip)
{
$this->attributes['zip'] = $zip ?: '*';
}
public function getTotalAttribute($total)
{
return Money::inDefaultCurrency($total);
}
}