Files
marcoandClaude Sonnet 4.6 41078fdc08 Initial commit: WitShop Laravel Online-Shop
- Laravel 11, Blade, Alpine.js, Tailwind CSS
- Produkt- & Kategorieverwaltung mit Varianten
- Checkout (Vorkasse + Rechnung), Session-Warenkorb
- Admin-Backend (Dashboard, Bestellungen, Kunden, CMS)
- DSGVO-konform: Cookie-Consent, Impressum, Widerruf, AGB
- PDF-Rechnung via dompdf, SMTP-Mailversand
- Kundenverwaltung mit manueller Freischaltung

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-20 00:34:09 +02:00

35 lines
924 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class OrderItem extends Model
{
protected $fillable = ['order_id','product_variant_id','product_name','variant_label','quantity','unit_price','tax_rate'];
protected $casts = ['unit_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
public function variant(): BelongsTo
{
return $this->belongsTo(ProductVariant::class, 'product_variant_id');
}
public function getLineTotalAttribute(): float
{
return round($this->unit_price * $this->quantity, 2);
}
public function getTaxAmountAttribute(): float
{
$net = $this->unit_price / (1 + $this->tax_rate / 100);
return round(($this->unit_price - $net) * $this->quantity, 2);
}
}