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

@ -69,7 +69,9 @@ class Homeparty extends Model
'order_to' => 'bool',
'active' => 'bool',
'default' => 'bool',
'token_active' => 'bool'
'token_active' => 'bool',
'settings' => 'array',
'order' => 'array'
];
protected $dates = [
@ -94,6 +96,8 @@ class Homeparty extends Model
'default',
'token',
'token_active',
'settings',
'order'
];
public function auth_user()

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;
}
}

View file

@ -174,6 +174,8 @@ class Product extends Model
'show_order' => 'Wird immer als Option angezeigt',
'upgrade' => 'Produktupgrade zur Produkt ID',
'upgrade_member' => 'Beraterupgrade zur Karriere ID',
'proportional_voucher' => 'Anteiliger Gutschein Berater',
];
public $unitTypes = [
@ -192,6 +194,7 @@ class Product extends Model
4 => 'Nur Mitgliedschaft Berater',
5 => 'Onboarding Berater',
6 => 'Onboarding Berater + Berater Shop',
7 => 'zur internen Berechnung',
];

View file

@ -43,6 +43,7 @@ class ShoppingInstance extends Model
2 => 'Berater Shop',
3 => 'Berater Membership',
4 => 'Berater Wizard',
5 => 'Berater Homeparty',
];
protected $table = 'shopping_instances';

View file

@ -92,6 +92,7 @@ class ShoppingOrder extends Model
'shopping_user_id',
'auth_user_id',
'member_id',
'homeparty_id',
'country_id',
'user_shop_id',
'total',
@ -143,6 +144,11 @@ class ShoppingOrder extends Model
return $this->belongsTo('App\Models\ShippingCountry','country_id');
}
public function homeparty()
{
return $this->belongsTo('App\Models\Homeparty','homeparty_id');
}
public function user_shop()
{
return $this->belongsTo('App\Models\UserShop','user_shop_id');

View file

@ -57,6 +57,7 @@ class ShoppingOrderItem extends Model
'shopping_order_id',
'row_id',
'product_id',
'homeparty_id',
'comp',
'qty',
'price',
@ -76,6 +77,11 @@ class ShoppingOrderItem extends Model
return $this->belongsTo('App\Models\Product','product_id');
}
public function homeparty()
{
return $this->belongsTo('App\Models\Homeparty','homeparty_id');
}
public function getFormattedPrice()
{
return formatNumber($this->attributes['price']);

View file

@ -160,6 +160,7 @@ class ShoppingUser extends Model
'is_for',
'is_from',
'shopping_user_id',
'homeparty_id',
'wp_order_number',
'wp_order_date',
];

View file

@ -79,11 +79,11 @@ class UserHistory extends Model
2 => 'warning',
3 => 'danger',
4 => 'warning',
5 => 'success',
5 => 'warning',
6 => 'danger',
7 => 'warning',
8 => 'success',
9 => 'success',
9 => 'secondary',
10 => 'success',
21 => 'danger',
22 => 'danger',