Homparty v1.0

This commit is contained in:
Kevin Adametz 2020-12-17 23:02:22 +01:00
parent ac0d5b781e
commit c73299e52e
40 changed files with 1234 additions and 908 deletions

View file

@ -123,7 +123,9 @@ class HomepartyUser extends Model
'shipping_country_id' => 'int',
'has_buyed' => 'bool',
'subscribed' => 'bool',
];
'settings' => 'array',
];
protected $dates = [
'user_deleted_at'
@ -161,7 +163,9 @@ class HomepartyUser extends Model
'subscribed',
'notice',
'mode',
'user_deleted_at'
'settings',
'delivery',
'user_deleted_at'
];
public function homeparty()
@ -190,9 +194,27 @@ class HomepartyUser extends Model
}
public function isAddress(){
if($this->billing_firstname !== null){
if($this->billing_firstname !== null && $this->billing_country_id !== null){
return true;
}
return false;
}
public function getDelivery(){
return $this->delivery === 'direct' ? 'direct' : 'host';
}
public function getShipping(){
if($this->same_as_billing){
$country_id = $this->billing_country_id != null ? $this->billing_country_id : 1;
}else{
$country_id = $this->shipping_country_id != null ? $this->shipping_country_id : 1;
}
$shippingCountry = ShippingCountry::whereCountryId($country_id)->first();
if(!$shippingCountry){
return null;
}
return $shippingCountry->shipping;
}
}