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>
This commit is contained in:
2026-06-20 00:34:09 +02:00
co-authored by Claude Sonnet 4.6
commit 41078fdc08
208 changed files with 21725 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Address extends Model
{
protected $fillable = ['user_id','first_name','last_name','company','street','street2','zip','city','country','phone','is_default'];
protected $casts = ['is_default' => 'boolean'];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Attribute extends Model
{
protected $fillable = ['name'];
public function values(): HasMany
{
return $this->hasMany(AttributeValue::class)->orderBy('sort_order');
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class AttributeValue extends Model
{
protected $fillable = ['attribute_id','value','sort_order'];
public function attribute(): BelongsTo
{
return $this->belongsTo(Attribute::class);
}
public function variants(): BelongsToMany
{
return $this->belongsToMany(ProductVariant::class, 'product_variant_attribute_values');
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Banner extends Model
{
protected $fillable = ['image','headline','subtext','button_label','button_link','sort_order','active'];
protected $casts = ['active' => 'boolean'];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Category extends Model
{
protected $fillable = ['parent_id','name','slug','description','image','sort_order','active'];
protected $casts = ['active' => 'boolean'];
public function parent(): BelongsTo
{
return $this->belongsTo(Category::class, 'parent_id');
}
public function children(): HasMany
{
return $this->hasMany(Category::class, 'parent_id')->orderBy('sort_order');
}
public function products(): HasMany
{
return $this->hasMany(Product::class);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Faq extends Model
{
protected $fillable = ['faq_group_id','question','answer','sort_order'];
public function group(): BelongsTo
{
return $this->belongsTo(FaqGroup::class, 'faq_group_id');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class FaqGroup extends Model
{
protected $fillable = ['name','sort_order'];
public function faqs(): HasMany
{
return $this->hasMany(Faq::class)->orderBy('sort_order');
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Order extends Model
{
protected $fillable = [
'order_number','user_id','guest_email','status','payment_method',
'subtotal','tax_total','shipping_cost','total','tracking_code','notes','paid_at',
];
protected $casts = [
'paid_at' => 'datetime',
'subtotal' => 'decimal:2',
'tax_total' => 'decimal:2',
'shipping_cost' => 'decimal:2',
'total' => 'decimal:2',
];
public static array $statusLabels = [
'new' => 'Neu',
'payment_received' => 'Zahlung eingegangen',
'processing' => 'In Bearbeitung',
'shipped' => 'Versendet',
'completed' => 'Abgeschlossen',
'cancelled' => 'Storniert',
];
public static array $paymentLabels = [
'prepayment' => 'Vorkasse',
'invoice' => 'Rechnung',
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function items(): HasMany
{
return $this->hasMany(OrderItem::class);
}
public function addresses(): HasMany
{
return $this->hasMany(OrderAddress::class);
}
public function billingAddress()
{
return $this->addresses()->where('type', 'billing')->first();
}
public function shippingAddress()
{
return $this->addresses()->where('type', 'shipping')->first();
}
public function getStatusLabelAttribute(): string
{
return self::$statusLabels[$this->status] ?? $this->status;
}
public function getPaymentLabelAttribute(): string
{
return self::$paymentLabels[$this->payment_method] ?? $this->payment_method;
}
public static function generateOrderNumber(): string
{
return 'ORD-' . date('Ymd') . '-' . strtoupper(substr(uniqid(), -5));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class OrderAddress extends Model
{
protected $fillable = ['order_id','type','first_name','last_name','company','street','street2','zip','city','country','phone'];
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
public function getFullNameAttribute(): string
{
return trim("{$this->first_name} {$this->last_name}");
}
}
+34
View File
@@ -0,0 +1,34 @@
<?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);
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
protected $fillable = ['slug','title','content','type','image','meta_title','meta_description','published','published_at','show_in_footer','show_in_nav','nav_sort'];
protected $casts = ['published' => 'boolean', 'published_at' => 'datetime', 'show_in_footer' => 'boolean', 'show_in_nav' => 'boolean'];
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Product extends Model
{
protected $fillable = ['category_id','name','slug','description','base_price','tax_rate','weight','active','featured','track_stock','sort_order'];
protected $casts = ['active' => 'boolean', 'featured' => 'boolean', 'track_stock' => 'boolean', 'base_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function images(): HasMany
{
return $this->hasMany(ProductImage::class)->orderBy('sort_order');
}
public function variants(): HasMany
{
return $this->hasMany(ProductVariant::class);
}
/** Effektiver Bruttopreis (Basispreis, wenn keine Variante gewählt) */
public function getDisplayPriceAttribute(): float
{
return (float) $this->base_price;
}
public function getNetPriceAttribute(): float
{
return round($this->base_price / (1 + $this->tax_rate / 100), 2);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductImage extends Model
{
protected $fillable = ['product_id','path','sort_order'];
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class ProductVariant extends Model
{
protected $fillable = ['product_id','sku','price_override','stock','stock_warning','active'];
protected $casts = ['active' => 'boolean', 'price_override' => 'decimal:2'];
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function attributeValues(): BelongsToMany
{
return $this->belongsToMany(AttributeValue::class, 'product_variant_attribute_values')
->with('attribute');
}
public function getEffectivePriceAttribute(): float
{
return (float) ($this->price_override ?? $this->product->base_price);
}
public function getLabelAttribute(): string
{
return $this->attributeValues->map(fn($v) => $v->value)->join(', ');
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class Setting extends Model
{
protected $fillable = ['key','value'];
public static function get(string $key, mixed $default = null): mixed
{
return Cache::remember("setting_{$key}", 3600, function () use ($key, $default) {
return self::where('key', $key)->value('value') ?? $default;
});
}
public static function set(string $key, mixed $value): void
{
self::updateOrCreate(['key' => $key], ['value' => $value]);
Cache::forget("setting_{$key}");
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ShippingRate extends Model
{
protected $fillable = ['name','zone','price','free_from','active'];
protected $casts = ['active' => 'boolean', 'price' => 'decimal:2', 'free_from' => 'decimal:2'];
public static function forCart(float $total, string $zone = 'DE'): ?self
{
return self::where('zone', $zone)->where('active', true)->first();
}
public function getCostForTotal(float $total): float
{
if ($this->free_from !== null && $total >= (float) $this->free_from) {
return 0.0;
}
return (float) $this->price;
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable;
protected $fillable = ['name', 'email', 'password', 'role', 'approved'];
protected $hidden = ['password', 'remember_token'];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'approved' => 'boolean',
];
}
public function isApproved(): bool
{
return $this->isAdmin() || (bool) $this->approved;
}
public function isAdmin(): bool
{
return in_array($this->role, ['admin', 'super_admin']);
}
public function isSuperAdmin(): bool
{
return $this->role === 'super_admin';
}
public function addresses(): HasMany
{
return $this->hasMany(Address::class);
}
public function orders(): HasMany
{
return $this->hasMany(Order::class);
}
}