@extends('layouts.app') @section('style') @endsection @section('content')
Price Changes Today
{{ $stats['total_changes_today'] }}
Daily average: {{ round($stats['avg_daily_changes'], 1) }} @if($stats['total_changes_today'] > $stats['avg_daily_changes']) Above average @else Below average @endif
Price Changes This Week
{{ $stats['total_changes_week'] }}
Weekly trend @php $lastWeek = PriceHistory::where('created_at', '>=', now()->subDays(14)) ->where('created_at', '<', now()->subDays(7)) ->count(); $weekChange = $lastWeek > 0 ? (($stats['total_changes_week'] - $lastWeek) / $lastWeek) * 100 : 0; @endphp @if($weekChange > 0) {{ round($weekChange, 1) }}% @else {{ round(abs($weekChange), 1) }}% @endif
Price Changes This Month
{{ $stats['total_changes_month'] }}
Monthly overview @php $lastMonth = PriceHistory::where('created_at', '>=', now()->subDays(60)) ->where('created_at', '<', now()->subDays(30)) ->count(); $monthChange = $lastMonth > 0 ? (($stats['total_changes_month'] - $lastMonth) / $lastMonth) * 100 : 0; @endphp @if($monthChange > 0) {{ round($monthChange, 1) }}% @else {{ round(abs($monthChange), 1) }}% @endif
Recent Price Changes
@if($recentChanges->isEmpty())
No recent price changes
@else
@foreach($recentChanges as $change)
{{ $change->created_at->diffForHumans() }}
{{ $change->product->name }} - {{ $change->price_type_label }} changed from ${{ number_format($change->old_price, 2) }} to ${{ number_format($change->new_price, 2) }} @php $changeAmount = $change->new_price - $change->old_price; @endphp @if($changeAmount > 0) +${{ number_format($changeAmount, 2) }} @elseif($changeAmount < 0) -${{ number_format(abs($changeAmount), 2) }} @endif
By {{ $change->user->name ?? 'System' }} • {{ $change->change_reason }}
@endforeach
@endif
Most Active Products (Last 30 Days)
@if($stats['most_active_products']->isEmpty())

No price changes in the last 30 days

@else
@foreach($stats['most_active_products'] as $item) @endforeach
Product SKU Price Changes Current Price Last Change
{{ $item->product->name }} {{ $item->product->sku }} {{ $item->changes }} ${{ number_format($item->product->sale_price, 2) }} @php $lastChange = PriceHistory::where('product_id', $item->product_id) ->latest() ->first(); @endphp @if($lastChange) {{ $lastChange->created_at->diffForHumans() }} @else N/A @endif
@endif
Largest Price Changes
Largest Increase
@if($stats['largest_increase'])
{{ $stats['largest_increase']->product->name }}
+${{ number_format($stats['largest_increase']->new_price - $stats['largest_increase']->old_price, 2) }}
{{ $stats['largest_increase']->created_at->diffForHumans() }}
@else

No price increases recorded

@endif
Largest Decrease
@if($stats['largest_decrease'])
{{ $stats['largest_decrease']->product->name }}
-${{ number_format($stats['largest_decrease']->old_price - $stats['largest_decrease']->new_price, 2) }}
{{ $stats['largest_decrease']->created_at->diffForHumans() }}
@else

No price decreases recorded

@endif
Summary Statistics
{{ PriceHistory::count() }}
Total Changes
{{ Product::count() }}
Total Products
{{ PriceHistory::distinct('product_id')->count() }}
Products with Changes
{{ User::count() }}
Users Made Changes
@endsection @section('script') @endsection