20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
|
|
@ -3,8 +3,89 @@
|
|||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class ProductVariant extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = [
|
||||
'product_id',
|
||||
'name_suffix',
|
||||
'is_master_variant',
|
||||
'sku',
|
||||
'han_mpn',
|
||||
'ean_gtin',
|
||||
'selling_price',
|
||||
'msrp',
|
||||
'purchase_price',
|
||||
'tax_rate_id',
|
||||
'stock_quantity',
|
||||
'stock_min_threshold',
|
||||
'availability_status',
|
||||
'delivery_time_text',
|
||||
'currency',
|
||||
'is_rentable',
|
||||
'rental_duration_options',
|
||||
'rental_rate_formula',
|
||||
'residual_value_percentage',
|
||||
'variant_weight_g',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_master_variant' => 'boolean',
|
||||
'selling_price' => 'integer',
|
||||
'msrp' => 'integer',
|
||||
'purchase_price' => 'integer',
|
||||
'stock_quantity' => 'integer',
|
||||
'is_rentable' => 'boolean',
|
||||
'rental_duration_options' => 'array',
|
||||
'residual_value_percentage' => 'decimal:2',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gehört zu einem Produkt.
|
||||
*/
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Steuersatz der Variante.
|
||||
*/
|
||||
public function taxRate(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TaxRate::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribut-Werte dieser Variante (z.B. Farbe: Rot, Größe: L).
|
||||
*/
|
||||
public function attributeValues(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(AttributeValue::class, 'product_variant_attributes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logistik-Daten der Variante (1:1).
|
||||
*/
|
||||
public function logistics(): HasOne
|
||||
{
|
||||
return $this->hasOne(ProductLogistics::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bilder der Variante.
|
||||
*/
|
||||
public function media(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Media::class, 'model');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue