April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -5,8 +5,12 @@ namespace App\Models;
|
|||
use App\Services\Type;
|
||||
use App\Services\Util;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* App\Models\Product
|
||||
|
|
@ -34,13 +38,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property int|null $pos
|
||||
* @property int $active
|
||||
* @property int|null $amount
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductAttribute[] $attributes
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $images
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property-read Collection|ProductAttribute[] $attributes
|
||||
* @property-read Collection|ProductCategory[] $categories
|
||||
* @property-read Collection|ProductImage[] $images
|
||||
* @property-write mixed $price_vk
|
||||
*
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
|
|
@ -72,78 +77,102 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUsage($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
|
||||
*
|
||||
* @property string|null $slug
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product query()
|
||||
*
|
||||
* @property int|null $weight
|
||||
* @property int|null $show_at
|
||||
* @property array|null $action
|
||||
* @property-read int|null $attributes_count
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read int|null $images_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWeight($value)
|
||||
*
|
||||
* @property int|null $points
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductImage[] $imagesActive
|
||||
* @property-read Collection|ProductImage[] $imagesActive
|
||||
* @property-read int|null $images_active_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product wherePoints($value)
|
||||
*
|
||||
* @property string|null $identifier
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereIdentifier($value)
|
||||
*
|
||||
* @property int|null $upgrade_to_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUpgradeToId($value)
|
||||
*
|
||||
* @property int|null $contents_total
|
||||
* @property int|null $unit
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereContentsTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUnit($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
|
||||
*
|
||||
* @property-read Collection|CountryPrice[] $country_prices
|
||||
* @property-read int|null $country_prices_count
|
||||
* @property int|null $wp_number
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
|
||||
*
|
||||
* @property bool|null $single_commission
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShippingAddon($value)
|
||||
*
|
||||
* @property-read int|null $ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
|
||||
* @property-read Collection|ProductIngredient[] $product_ingredients
|
||||
* @property-read int|null $product_ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
|
||||
* @property-read Collection|Ingredient[] $p_ingredients
|
||||
* @property-read int|null $p_ingredients_count
|
||||
* @property bool $amount_commission
|
||||
* @property string|null $value_commission
|
||||
* @property string|null $partner_commission
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereAmountCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product wherePartnerCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereSingleCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereValueCommission($value)
|
||||
*
|
||||
* @property bool|null $shipping_addon
|
||||
* @property bool|null $max_buy
|
||||
* @property int|null $max_buy_num
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductBuy[] $product_buys
|
||||
* @property-read Collection|ProductBuy[] $product_buys
|
||||
* @property-read int|null $product_buys_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuy($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereMaxBuyNum($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*
|
||||
* @property string|null $short_copy
|
||||
* @property array|null $show_on
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShortCopy($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
|
||||
*
|
||||
* @property bool $exclude_stats_sales
|
||||
* @property bool|null $whitelabel
|
||||
* @property string|null $whitelabel_name
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductAttribute> $attribute_variants
|
||||
* @property-read Collection<int, ProductAttribute> $attribute_variants
|
||||
* @property-read int|null $attribute_variants_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductImage> $whitelabel_images
|
||||
* @property-read Collection<int, ProductImage> $whitelabel_images
|
||||
* @property-read int|null $whitelabel_images_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereExcludeStatsSales($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabel($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereWhitelabelName($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
||||
/*identifiers
|
||||
show_upgrade # in membership payment can upgrade this package to show order
|
||||
show_order # in membership payment show always
|
||||
|
|
@ -172,8 +201,8 @@ class Product extends Model
|
|||
'max_buy_num' => 'int',
|
||||
'whitelabel' => 'bool',
|
||||
];
|
||||
use Sluggable;
|
||||
|
||||
use Sluggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
|
@ -215,7 +244,9 @@ class Product extends Model
|
|||
'upgrade_to_id',
|
||||
'shipping_addon',
|
||||
'max_buy',
|
||||
'max_buy_num'
|
||||
'max_buy_num',
|
||||
'shelf_life_type',
|
||||
'shelf_life_months',
|
||||
|
||||
];
|
||||
|
||||
|
|
@ -225,8 +256,9 @@ class Product extends Model
|
|||
'show_order' => 'Wird immer als Option angezeigt',
|
||||
'upgrade' => 'Produktupgrade zur Produkt ID',
|
||||
'upgrade_member' => 'Vertriebspartnerupgrade zur Karriere ID',
|
||||
//'proportional_voucher' => 'Anteiliger Gutschein Vertriebspartner',
|
||||
// 'proportional_voucher' => 'Anteiliger Gutschein Vertriebspartner',
|
||||
];
|
||||
|
||||
public $unitTypes = [
|
||||
0 => '',
|
||||
1 => 'ml',
|
||||
|
|
@ -238,9 +270,9 @@ class Product extends Model
|
|||
public $actions = [
|
||||
0 => 'payment_for_account',
|
||||
1 => 'charging_credits',
|
||||
// 1 => 'payment_for_shop',
|
||||
// 2 => 'payment_for_shop_upgrade',
|
||||
// 4 => 'payment_for_lead_upgrade',
|
||||
// 1 => 'payment_for_shop',
|
||||
// 2 => 'payment_for_shop_upgrade',
|
||||
// 4 => 'payment_for_lead_upgrade',
|
||||
|
||||
];
|
||||
|
||||
|
|
@ -248,34 +280,39 @@ class Product extends Model
|
|||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
'source' => 'name',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(){
|
||||
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','!=', 1);
|
||||
public function attributes()
|
||||
{
|
||||
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id', '!=', 1);
|
||||
}
|
||||
|
||||
public function attribute_variants(){
|
||||
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id','=', 1);
|
||||
public function attribute_variants()
|
||||
{
|
||||
return $this->hasMany(ProductAttribute::class, 'product_id', 'id')->where('type_id', '=', 1);
|
||||
}
|
||||
|
||||
|
||||
public function categories(){
|
||||
public function categories()
|
||||
{
|
||||
return $this->hasMany('App\Models\ProductCategory', 'product_id', 'id');
|
||||
}
|
||||
|
||||
public function images(){
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->orderBy('pos');
|
||||
public function images()
|
||||
{
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'product')->orderBy('pos');
|
||||
}
|
||||
|
||||
public function imagesActive(){
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'product')->where('active', true)->orderBy('pos');
|
||||
public function imagesActive()
|
||||
{
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'product')->where('active', true)->orderBy('pos');
|
||||
}
|
||||
|
||||
public function whitelabel_images(){
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type','=', 'wllogo')->orderBy('pos');
|
||||
public function whitelabel_images()
|
||||
{
|
||||
return $this->hasMany(ProductImage::class, 'product_id', 'id')->where('type', '=', 'wllogo')->orderBy('pos');
|
||||
}
|
||||
|
||||
public function country_prices()
|
||||
|
|
@ -291,81 +328,130 @@ class Product extends Model
|
|||
public function p_ingredients()
|
||||
{
|
||||
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
|
||||
->withPivot('id')
|
||||
->withTimestamps();
|
||||
->withPivot('id', 'pos', 'gram', 'factor', 'recipe_type')
|
||||
->withTimestamps()
|
||||
->wherePivot('recipe_type', 'product')
|
||||
->orderByPivot('pos');
|
||||
}
|
||||
|
||||
public function manufacturer_ingredients()
|
||||
{
|
||||
return $this->belongsToMany(Ingredient::class, 'product_ingredients')
|
||||
->withPivot('id', 'pos', 'gram', 'factor', 'recipe_type')
|
||||
->withTimestamps()
|
||||
->wherePivot('recipe_type', 'manufacturer')
|
||||
->orderByPivot('pos');
|
||||
}
|
||||
|
||||
public function product_ingredients()
|
||||
{
|
||||
return $this->hasMany(ProductIngredient::class, 'product_ingredients', 'id');
|
||||
return $this->hasMany(ProductIngredient::class, 'product_id');
|
||||
}
|
||||
|
||||
public function getShortCopy($clean = false, $len = false){
|
||||
/**
|
||||
* Verpackungs-Stückliste (BOM) am Produkt mit Menge und Reihenfolge.
|
||||
*
|
||||
* @return BelongsToMany<PackagingItem, $this>
|
||||
*/
|
||||
public function packagings()
|
||||
{
|
||||
return $this->belongsToMany(PackagingItem::class, 'product_packagings')
|
||||
->withPivot('quantity', 'pos')
|
||||
->withTimestamps()
|
||||
->orderByPivot('pos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Production, $this>
|
||||
*/
|
||||
public function productions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Production::class);
|
||||
}
|
||||
|
||||
public function getShortCopy($clean = false, $len = false)
|
||||
{
|
||||
$ret = $this->short_copy ? $this->short_copy : $this->description;
|
||||
if($len && $clean){
|
||||
if ($len && $clean) {
|
||||
return substr_ellipsis($ret, $len, $clean);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
public function getActionName($id = 0){
|
||||
if(isset($this->actions[$id])){
|
||||
|
||||
public function getActionName($id = 0)
|
||||
{
|
||||
if (isset($this->actions[$id])) {
|
||||
return $this->actions[$id];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getWhiteLableName($id = 0){
|
||||
public function getWhiteLableName($id = 0)
|
||||
{
|
||||
return $this->whitelabel_name ? $this->whitelabel_name : $this->name;
|
||||
}
|
||||
|
||||
public function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
|
||||
public function _format_number($value)
|
||||
{
|
||||
return preg_replace('/[^0-9,]/', '', $value);
|
||||
}
|
||||
|
||||
public function setPriceAttribute( $value ) {
|
||||
public function setPriceAttribute($value)
|
||||
{
|
||||
|
||||
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceEkAttribute( $value ) {
|
||||
|
||||
public function setPriceEkAttribute($value)
|
||||
{
|
||||
|
||||
$this->attributes['price_ek'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setTaxAttribute( $value ) {
|
||||
|
||||
$this->attributes['tax'] = $value != "" ? Util::reFormatNumber($value) : null;
|
||||
public function setTaxAttribute($value)
|
||||
{
|
||||
|
||||
$this->attributes['tax'] = $value != '' ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceOldAttribute( $value ) {
|
||||
|
||||
public function setPriceOldAttribute($value)
|
||||
{
|
||||
|
||||
$this->attributes['price_old'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setValueCommissionAttribute( $value ) {
|
||||
public function setValueCommissionAttribute($value)
|
||||
{
|
||||
$this->attributes['value_commission'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function setPartnerCommissionAttribute( $value ) {
|
||||
public function setPartnerCommissionAttribute($value)
|
||||
{
|
||||
$this->attributes['partner_commission'] = $value ? Util::reFormatNumber($value) : 0;
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : '';
|
||||
}
|
||||
|
||||
public function getFormattedPriceEk()
|
||||
{
|
||||
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
|
||||
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : '';
|
||||
}
|
||||
|
||||
public function getFormattedTax($country = null)
|
||||
{
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : '';
|
||||
}
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : '';
|
||||
}
|
||||
|
||||
public function getFormattedValueCommission()
|
||||
{
|
||||
return isset($this->attributes['value_commission']) ? Util::formatNumber($this->attributes['value_commission']) : 0;
|
||||
|
|
@ -376,9 +462,9 @@ class Product extends Model
|
|||
return isset($this->attributes['partner_commission']) ? Util::formatNumber($this->attributes['partner_commission']) : 0;
|
||||
}
|
||||
|
||||
|
||||
/*price by user Factor*/
|
||||
private function calcPriceUserFactor($price){
|
||||
/* price by user Factor */
|
||||
private function calcPriceUserFactor($price)
|
||||
{
|
||||
/*
|
||||
Nicht in benutzung, die margin errechnet sich im Warenkorb, wegen der Staffelprovision
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
|
|
@ -388,98 +474,116 @@ class Product extends Model
|
|||
*/
|
||||
return $price;
|
||||
}
|
||||
/*price net*/
|
||||
private function calcPriceNet($price, $country=null){
|
||||
|
||||
/* price net */
|
||||
private function calcPriceNet($price, $country = null)
|
||||
{
|
||||
$tax = $this->getTaxWith($country);
|
||||
$tax_rate = ($tax + 100) / 100;
|
||||
$tax_rate = ($tax + 100) / 100;
|
||||
|
||||
return $price / $tax_rate;
|
||||
}
|
||||
|
||||
//price calu with
|
||||
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false){
|
||||
// price calu with
|
||||
public function getPriceWith(bool $net = true, bool $ufactor = true, $country = null, $commission = false)
|
||||
{
|
||||
$price = isset($this->attributes['price']) ? $this->attributes['price'] : null;
|
||||
|
||||
|
||||
/*$cprice = $country ? $this->getCPrice($country) : null; //eigener Preis für Land
|
||||
$price = $cprice ? $cprice : $price; */
|
||||
|
||||
$price = $net ? $this->calcPriceNet($price, $country) : $price;
|
||||
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
|
||||
$price = $commission ? $this->calcPriceUserCommission($price) : $price;
|
||||
|
||||
return round($price, 2);
|
||||
}
|
||||
|
||||
/*out*/
|
||||
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true)
|
||||
/* out */
|
||||
public function getFormattedPriceWith(bool $net = true, bool $ufactor = true)
|
||||
{
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : "";
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : '';
|
||||
}
|
||||
|
||||
public function getTaxWith($country = null){
|
||||
public function getTaxWith($country = null)
|
||||
{
|
||||
$tax = isset($this->attributes['tax']) ? $this->attributes['tax'] : null;
|
||||
$ctax = $country ? $this->getCTax($country) : null;
|
||||
|
||||
return $ctax !== null ? $ctax : $tax;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getBasePriceFormattedFull(){
|
||||
if($price = $this->getBasePrice()){
|
||||
public function getBasePriceFormattedFull()
|
||||
{
|
||||
if ($price = $this->getBasePrice()) {
|
||||
$unit = $this->attributes['unit'];
|
||||
//ml g
|
||||
if($unit === 1 || $unit === 2){
|
||||
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
|
||||
// ml g
|
||||
if ($unit === 1 || $unit === 2) {
|
||||
return Util::formatNumber($price).' € / 100 '.$this->getUnitType();
|
||||
}
|
||||
//l kg
|
||||
if($unit === 3 || $unit === 4){
|
||||
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
|
||||
// l kg
|
||||
if ($unit === 3 || $unit === 4) {
|
||||
return Util::formatNumber($price).' € / 1 '.$this->getUnitType();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getBasePriceFormatted(){
|
||||
if($price = $this->getBasePrice()){
|
||||
public function getBasePriceFormatted()
|
||||
{
|
||||
if ($price = $this->getBasePrice()) {
|
||||
return Util::formatNumber($price);
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getBasePrice(){
|
||||
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
|
||||
public function getBasePrice()
|
||||
{
|
||||
if (isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0) {
|
||||
$unit = $this->attributes['unit'];
|
||||
//ml g
|
||||
if($unit === 1 || $unit === 2){
|
||||
// ml g
|
||||
if ($unit === 1 || $unit === 2) {
|
||||
return $this->attributes['price'] * 100 / $this->attributes['contents_total'];
|
||||
}
|
||||
//l kg
|
||||
if($unit === 3 || $unit === 4){
|
||||
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
|
||||
// l kg
|
||||
if ($unit === 3 || $unit === 4) {
|
||||
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
return '';
|
||||
}
|
||||
public function getUnitType(){
|
||||
|
||||
public function getUnitType()
|
||||
{
|
||||
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
|
||||
}
|
||||
public function getShowAtType(){
|
||||
|
||||
public function getShowAtType()
|
||||
{
|
||||
return isset(Type::$showATs[$this->show_at]) ? Type::$showATs[$this->show_at] : '-';
|
||||
}
|
||||
|
||||
public function getShowOnTypes($seperator = false){
|
||||
public function getShowOnTypes($seperator = false)
|
||||
{
|
||||
$ret = [];
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
if ($this->show_on && is_array($this->show_on)) {
|
||||
foreach ($this->show_on as $show) {
|
||||
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
|
||||
}
|
||||
}
|
||||
|
||||
return $seperator ? implode($seperator, $ret) : $ret;
|
||||
}
|
||||
|
||||
|
||||
public function setPosAttribute($value){
|
||||
public function setPosAttribute($value)
|
||||
{
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
|
|
@ -487,62 +591,75 @@ class Product extends Model
|
|||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
if (!$trans || $trans == '') {
|
||||
if (! $trans || $trans == '') {
|
||||
return $this->{$key};
|
||||
}
|
||||
|
||||
return $trans;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
$key = 'trans_'.$key;
|
||||
if (! empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
}
|
||||
|
||||
public function getTranNames()
|
||||
{
|
||||
$ret = "";
|
||||
foreach ((array) $this->trans_name as $value){
|
||||
$ret = '';
|
||||
foreach ((array) $this->trans_name as $value) {
|
||||
$ret .= $value.', ';
|
||||
}
|
||||
|
||||
return rtrim($ret, ', ');
|
||||
}
|
||||
|
||||
public function getCountryPrice($country_id){
|
||||
return $this->country_prices->where('country_id', '=', $country_id)->first() ?: new CountryPrice();
|
||||
public function getCountryPrice($country_id)
|
||||
{
|
||||
return $this->country_prices->where('country_id', '=', $country_id)->first() ?: new CountryPrice;
|
||||
}
|
||||
|
||||
public function getCPrice($country_id){
|
||||
public function getCPrice($country_id)
|
||||
{
|
||||
return $this->getCountryPrice($country_id)->c_price;
|
||||
}
|
||||
public function getCTax($country_id){
|
||||
|
||||
public function getCTax($country_id)
|
||||
{
|
||||
return $this->getCountryPrice($country_id)->c_tax;
|
||||
}
|
||||
public function getCPriceOld($country_id){
|
||||
|
||||
public function getCPriceOld($country_id)
|
||||
{
|
||||
return $this->getCountryPrice($country_id)->c_price_old;
|
||||
}
|
||||
public function getCCurrency($country_id){
|
||||
|
||||
public function getCCurrency($country_id)
|
||||
{
|
||||
return $this->getCountryPrice($country_id)->c_currency;
|
||||
}
|
||||
|
||||
public function getRealPrice(Country $country){
|
||||
if($country->own_eur && $this->getCPrice($country->id)){
|
||||
public function getRealPrice(Country $country)
|
||||
{
|
||||
if ($country->own_eur && $this->getCPrice($country->id)) {
|
||||
return $this->getCPrice($country->id);
|
||||
}
|
||||
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function getFormattedPriceCurrencyWith(Bool $net = true, Bool $ufactor = true, Country $country = null, $commission = false){
|
||||
$ret = "";
|
||||
if($country && isset($country->currency) && $country->currency){
|
||||
$price = $this->getPriceWith($net, $ufactor, $country, $commission);
|
||||
$ret = formatNumber($price * $country->currency_faktor)." ".$country->currency_unit;
|
||||
public function getFormattedPriceCurrencyWith(bool $net = true, bool $ufactor = true, ?Country $country = null, $commission = false)
|
||||
{
|
||||
$ret = '';
|
||||
if ($country && isset($country->currency) && $country->currency) {
|
||||
$price = $this->getPriceWith($net, $ufactor, $country, $commission);
|
||||
$ret = formatNumber($price * $country->currency_faktor).' '.$country->currency_unit;
|
||||
|
||||
return '<br><span class="small">~'.$ret.'<span>';
|
||||
}
|
||||
return "" ;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue