23-01-2026
This commit is contained in:
parent
07959c0ba2
commit
854ce02bf6
166 changed files with 32909 additions and 1262 deletions
|
|
@ -1,57 +1,268 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Partner;
|
||||
use App\Models\User;
|
||||
use App\Models\RegistrationCode;
|
||||
use App\Helpers\ThemeHelper;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
public $userRole = '';
|
||||
public $roleIcon = 'shield-check';
|
||||
public $roleName = '';
|
||||
|
||||
// Admin KPIs
|
||||
public $activeHubs = 0;
|
||||
public $plannedHubs = 0;
|
||||
public $totalPartners = 0;
|
||||
public $partnersThisMonth = 0;
|
||||
public $platformRevenue = 0;
|
||||
public $systemStatus = 'green';
|
||||
public $pendingInvitations = 0;
|
||||
public $totalCustomers = 0;
|
||||
public array $data = [];
|
||||
|
||||
// Retailer KPIs
|
||||
public $openOrders = 0;
|
||||
public $monthlyRevenue = 0;
|
||||
public $productViews = 0;
|
||||
public $stockWarnings = 0;
|
||||
public $myCustomers = 0;
|
||||
|
||||
// Manufacturer KPIs
|
||||
public $brandReach = 0;
|
||||
public $activeProducts = 0;
|
||||
public $draftProducts = 0;
|
||||
public $totalViews = 0;
|
||||
|
||||
// Broker KPIs
|
||||
public $totalCommission = 0;
|
||||
public $pendingPayout = 0;
|
||||
public $generatedLeads = 0;
|
||||
public $referralLink = '';
|
||||
public $brokerCustomers = 0;
|
||||
|
||||
// Customer Brand Data
|
||||
public $customerBrand = 'b2in';
|
||||
public $customerBrandName = 'B2IN';
|
||||
public $customerBrandLogo = '';
|
||||
public $customerBrandColors = [];
|
||||
public $customerBrokerName = '';
|
||||
public $topOffers = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
$role = $user->roles->first();
|
||||
|
||||
if ($role) {
|
||||
$this->userRole = strtolower(str_replace('-', '', $role->name));
|
||||
$this->roleIcon = $role->icon ?? 'shield-check';
|
||||
$this->roleName = $role->display_name ?? $role->name;
|
||||
}
|
||||
|
||||
// Lade rollenspezifische Daten
|
||||
match ($this->userRole) {
|
||||
'admin', 'superadmin' => $this->loadAdminData(),
|
||||
'retailer' => $this->loadRetailerData($user),
|
||||
'manufacturer' => $this->loadManufacturerData($user),
|
||||
'broker', 'estateagent' => $this->loadBrokerData($user),
|
||||
'customer' => $this->loadCustomerData($user),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
private function loadAdminData(): void
|
||||
{
|
||||
// Platzhalter: Aktive Hubs (später aus Hub-Tabelle)
|
||||
$this->activeHubs = 3;
|
||||
$this->plannedHubs = 2;
|
||||
|
||||
// Partner-Wachstum
|
||||
$this->totalPartners = Partner::whereIn('type', ['Retailer', 'Manufacturer', 'Broker', 'Estate-Agent'])->count();
|
||||
$this->partnersThisMonth = Partner::whereIn('type', ['Retailer', 'Manufacturer', 'Broker', 'Estate-Agent'])
|
||||
->whereMonth('created_at', now()->month)
|
||||
->count();
|
||||
|
||||
// Platzhalter: Plattform-Umsatz
|
||||
$this->platformRevenue = 125000; // Später aus Order-Tabelle
|
||||
|
||||
// System-Status (Platzhalter)
|
||||
$this->systemStatus = 'green';
|
||||
|
||||
// Onboarding-Pipeline: Codes ohne registrierte User
|
||||
$this->pendingInvitations = RegistrationCode::whereNull('used_at')->count();
|
||||
|
||||
// Kunden gesamt
|
||||
$this->totalCustomers = Partner::where('type', 'Customer')->count();
|
||||
|
||||
$this->data = [
|
||||
['date' => '2025-12-11', 'visitors' => 50],
|
||||
['date' => '2025-12-12', 'visitors' => 70],
|
||||
['date' => '2025-12-13', 'visitors' => 100],
|
||||
['date' => '2025-12-14', 'visitors' => 210],
|
||||
['date' => '2025-12-15', 'visitors' => 198],
|
||||
['date' => '2025-12-16', 'visitors' => 269],
|
||||
['date' => '2025-12-17', 'visitors' => 259],
|
||||
['date' => '2025-12-18', 'visitors' => 267],
|
||||
];
|
||||
}
|
||||
|
||||
private function loadRetailerData(User $user): void
|
||||
{
|
||||
// Platzhalter: Offene Bestellungen
|
||||
$this->openOrders = 5; // Später aus Order-Tabelle
|
||||
|
||||
// Platzhalter: Umsatz diesen Monat
|
||||
$this->monthlyRevenue = 15500; // Später aus Order-Tabelle
|
||||
|
||||
// Platzhalter: Produkt-Views
|
||||
$this->productViews = 1250; // Später aus Analytics
|
||||
|
||||
// Platzhalter: Lager-Warnungen
|
||||
$this->stockWarnings = 3; // Später aus Product-Tabelle (stock < min_stock)
|
||||
|
||||
// Meine Kunden (Kunden die diesem Händler zugeordnet sind)
|
||||
if ($user->partner_id) {
|
||||
$this->myCustomers = Partner::where('type', 'Customer')
|
||||
->where('parent_partner_id', $user->partner_id)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
private function loadManufacturerData(User $user): void
|
||||
{
|
||||
// Platzhalter: Marken-Reichweite (Händler die meine Produkte führen)
|
||||
$this->brandReach = 12; // Später aus Produkt-Zuordnungen
|
||||
|
||||
// Platzhalter: Katalog-Status
|
||||
$this->activeProducts = 45; // Später aus Product-Tabelle (is_active = true)
|
||||
$this->draftProducts = 7; // Später aus Product-Tabelle (is_active = false)
|
||||
|
||||
// Platzhalter: Gesamt-Views
|
||||
$this->totalViews = 8900; // Später aus Analytics
|
||||
}
|
||||
|
||||
private function loadBrokerData(User $user): void
|
||||
{
|
||||
// Platzhalter: Verdiente Provision
|
||||
$this->totalCommission = 4250.50; // Später aus Commission-Tabelle
|
||||
|
||||
// Platzhalter: Offene Auszahlung
|
||||
$this->pendingPayout = 850.00; // Später aus Payout-Tabelle
|
||||
|
||||
// Generierte Leads (Kunden über diesen Makler)
|
||||
if ($user->partner_id) {
|
||||
$this->generatedLeads = Partner::where('type', 'Customer')
|
||||
->where('parent_partner_id', $user->partner_id)
|
||||
->count();
|
||||
|
||||
$this->brokerCustomers = $this->generatedLeads;
|
||||
}
|
||||
|
||||
// Empfehlungs-Link (Platzhalter)
|
||||
$partner = Partner::find($user->partner_id);
|
||||
if ($partner) {
|
||||
$this->referralLink = url('/register?ref=' . $partner->partner_number);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadCustomerData(User $user): void
|
||||
{
|
||||
// Kunde: Lade Brand-Daten vom Partner
|
||||
if ($user->partner_id) {
|
||||
$partner = Partner::find($user->partner_id);
|
||||
|
||||
if ($partner) {
|
||||
// Brand aus Partner-Datensatz
|
||||
$this->customerBrand = $partner->brand ?? 'b2in';
|
||||
$this->customerBrandName = ThemeHelper::getBrandName($this->customerBrand);
|
||||
$this->customerBrandLogo = ThemeHelper::getLogoPathForBrand($this->customerBrand, 'positive');
|
||||
$this->customerBrandColors = ThemeHelper::getBrandColors($this->customerBrand);
|
||||
|
||||
// Makler/Händler-Namen laden, falls vorhanden
|
||||
if ($partner->parent_partner_id) {
|
||||
$parentPartner = Partner::find($partner->parent_partner_id);
|
||||
if ($parentPartner) {
|
||||
$this->customerBrokerName = $parentPartner->display_name ?? $parentPartner->company_name ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
// Top-Angebote laden (Platzhalter - später aus Product-Tabelle)
|
||||
$this->topOffers = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'Designer Sofa "Luna"',
|
||||
'description' => 'Modernes 3-Sitzer Sofa mit Samtbezug',
|
||||
'price' => 1899.00,
|
||||
'original_price' => 2499.00,
|
||||
'discount' => 24,
|
||||
'image' => 'https://images.unsplash.com/photo-1555041469-a586c61ea9bc?w=400&h=300&fit=crop',
|
||||
'category' => 'Wohnzimmer',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'Esstisch "Nordic"',
|
||||
'description' => 'Massivholz Esstisch für 6-8 Personen',
|
||||
'price' => 899.00,
|
||||
'original_price' => 1299.00,
|
||||
'discount' => 31,
|
||||
'image' => 'https://images.unsplash.com/photo-1617806118233-18e1de247200?w=400&h=300&fit=crop',
|
||||
'category' => 'Esszimmer',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'Boxspringbett "Royal"',
|
||||
'description' => 'Premium Boxspringbett 180x200 cm',
|
||||
'price' => 1599.00,
|
||||
'original_price' => 2199.00,
|
||||
'discount' => 27,
|
||||
'image' => 'https://images.unsplash.com/photo-1505693416388-ac5ce068fe85?w=400&h=300&fit=crop',
|
||||
'category' => 'Schlafzimmer',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<x-layouts.app title="Dashboard">
|
||||
<div class="flex h-full w-full flex-1 flex-col gap-4 rounded-xl">
|
||||
<div class="grid auto-rows-min gap-4 md:grid-cols-3">
|
||||
<div class="relative aspect-video overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700 p-4">
|
||||
<livewire:notifications />
|
||||
@volt('dashboard')
|
||||
<div class="space-y-6">
|
||||
{{-- Header mit Rollenbadge --}}
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ __('Dashboard') }} (Beispiel)</flux:heading>
|
||||
<flux:subheading>{{ __('Willkommen zurück') }}, {{ Auth::user()->name }}!</flux:subheading>
|
||||
</div>
|
||||
<div class="relative aspect-video overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700">
|
||||
<flux:table>
|
||||
<flux:table.columns>
|
||||
<flux:table.column>Customer</flux:table.column>
|
||||
<flux:table.column>Date</flux:table.column>
|
||||
<flux:table.column>Status</flux:table.column>
|
||||
<flux:table.column>Amount</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
<flux:table.rows>
|
||||
<flux:table.row>
|
||||
<flux:table.cell>Lindsey Aminoff</flux:table.cell>
|
||||
<flux:table.cell>Jul 29, 10:45 AM</flux:table.cell>
|
||||
<flux:table.cell><flux:badge color="green" size="sm" inset="top bottom">Paid</flux:badge></flux:table.cell>
|
||||
<flux:table.cell variant="strong">$49.00</flux:table.cell>
|
||||
</flux:table.row>
|
||||
|
||||
<flux:table.row>
|
||||
<flux:table.cell>Hanna Lubin</flux:table.cell>
|
||||
<flux:table.cell>Jul 28, 2:15 PM</flux:table.cell>
|
||||
<flux:table.cell><flux:badge color="green" size="sm" inset="top bottom">Paid</flux:badge></flux:table.cell>
|
||||
<flux:table.cell variant="strong">$312.00</flux:table.cell>
|
||||
</flux:table.row>
|
||||
|
||||
<flux:table.row>
|
||||
<flux:table.cell>Kianna Bushevi</flux:table.cell>
|
||||
<flux:table.cell>Jul 30, 4:05 PM</flux:table.cell>
|
||||
<flux:table.cell><flux:badge color="zinc" size="sm" inset="top bottom">Refunded</flux:badge></flux:table.cell>
|
||||
<flux:table.cell variant="strong">$132.00</flux:table.cell>
|
||||
</flux:table.row>
|
||||
|
||||
<flux:table.row>
|
||||
<flux:table.cell>Gustavo Geidt</flux:table.cell>
|
||||
<flux:table.cell>Jul 27, 9:30 AM</flux:table.cell>
|
||||
<flux:table.cell><flux:badge color="green" size="sm" inset="top bottom">Paid</flux:badge></flux:table.cell>
|
||||
<flux:table.cell variant="strong">$31.00</flux:table.cell>
|
||||
</flux:table.row>
|
||||
</flux:table.rows>
|
||||
</flux:table>
|
||||
</div>
|
||||
<div class="relative aspect-video overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700">
|
||||
<x-placeholder-pattern class="absolute inset-0 size-full stroke-gray-900/20 dark:stroke-neutral-100/20" />
|
||||
<div class="flex items-center gap-2 px-3 py-2 bg-accent-50 dark:bg-accent-900/20 rounded-lg">
|
||||
@svg('heroicon-o-'.$roleIcon, 'w-5 h-5 text-accent-600 dark:text-accent-400')
|
||||
<span class="text-sm font-medium text-accent-700 dark:text-accent-300">
|
||||
{{ $roleName }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="relative h-full flex-1 overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700">
|
||||
<x-placeholder-pattern class="absolute inset-0 size-full stroke-gray-900/20 dark:stroke-neutral-100/20" />
|
||||
</div>
|
||||
|
||||
|
||||
{{-- Rollenspezifisches Dashboard laden --}}
|
||||
@if(in_array($userRole, ['admin', 'superadmin']))
|
||||
@include('admin.dashboards.admin')
|
||||
@elseif($userRole === 'retailer')
|
||||
@include('admin.dashboards.retailer')
|
||||
@elseif($userRole === 'manufacturer')
|
||||
@include('admin.dashboards.manufacturer')
|
||||
@elseif(in_array($userRole, ['broker', 'estateagent']))
|
||||
@include('admin.dashboards.broker')
|
||||
@elseif($userRole === 'customer')
|
||||
@include('admin.dashboards.customer')
|
||||
@else
|
||||
<flux:card>
|
||||
<div class="text-center py-8">
|
||||
<div class="text-zinc-500">{{ __('Dashboard für Ihre Rolle wird noch entwickelt.') }}</div>
|
||||
</div>
|
||||
</flux:card>
|
||||
@endif
|
||||
</div>
|
||||
@endvolt
|
||||
</x-layouts.app>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue