This commit is contained in:
Kevin Adametz 2022-06-15 18:08:45 +02:00
parent 9b0b5feb7e
commit 7a040c3e19
106 changed files with 4074 additions and 1349 deletions

View file

@ -163,6 +163,7 @@ class Product extends Model
'contents_total',
'unit',
'number',
'ean',
'wp_number',
'icons',
'description',
@ -183,8 +184,8 @@ class Product extends Model
'' => '-',
'show_upgrade' => 'Kann geupdatet werden',
'show_order' => 'Wird immer als Option angezeigt',
'upgrade' => 'Produktupgrade zur Produkt ID',
'upgrade_member' => 'Beraterupgrade zur Karriere ID',
'upgrade_product' => 'Produkt upgrade zur Produkt ID',
'upgrade_member' => 'Berater upgrade zur Karriere ID',
'proportional_voucher' => 'Anteiliger Gutschein Berater',
];
public $unitTypes = [
@ -224,6 +225,14 @@ class Product extends Model
];
public $actionNames = [
0 => 'Zahlung für Mitgliedschaft',
1 => 'Zahlung für Mitgliedschaft + Shop',
2 => 'Bei Zahlung Shop upgrade auf ID',
4 => 'Bei Zahlung Karriere upgrade auf ID',
];
public function sluggable()
{
return [
@ -249,6 +258,17 @@ class Product extends Model
return $this->hasMany('App\Models\ProductImage', 'product_id', 'id')->where('active', true)->orderBy('pos');
}
public function getImageUrl(){
if(count($this->imagesActive)){
return route('product_image', [$this->imagesActive->first()->slug]);
}
return "";
}
public function getProductUrl(){
return 'https://mivita.shop/produkte/alle-produkte/'.$this->slug;
}
public function country_prices()
{
return $this->hasMany(CountryPrice::class, 'product_id');
@ -267,13 +287,26 @@ class Product extends Model
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
}
public function getActionName($id = 0){
if(isset($this->actions[$id])){
return $this->actions[$id];
}
return false;
}
public function getUpgradeToIdName($from){
if($from === 'payment_for_shop_upgrade'){
$value = Product::find($this->upgrade_to_id);
}
if($from === 'payment_for_lead_upgrade'){
$value = UserLevel::find($this->upgrade_to_id);
}
if($value){
return $value->name;
}
return "not found";
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}