{{-- Reusable dashboard stat/list card. Use anywhere (MEC dashboard, reports, etc.). Metric card: List card: Use backgroundGradient for gradient, e.g. backgroundGradient="linear-gradient(180deg,#e65100,#ff9800)" Optional: iconBg (icon circle color), rounded (true/false), extra slot for footer content. Pass id, class via attributes. --}} @props([ 'type' => 'metric', 'background' => '#1A3B73', 'backgroundGradient' => null, 'number' => null, 'title' => '', 'icon' => null, 'subText' => null, 'meta' => null, 'trend' => null, 'layout' => 'compact', 'iconBg' => 'rgba(255,255,255,0.2)', 'items' => [], 'rounded' => true, ]) @once @push('styles') @endpush @endonce @php $isList = $type === 'list' || (empty($number) && empty($title) && !empty($items)); $bgStyle = $backgroundGradient ? 'background: ' . $backgroundGradient . ';' : 'background-color: ' . $background . ';'; @endphp
merge(['class' => 'dashboard-card dashboard-card--' . ($isList ? 'list' : 'metric') . ($rounded ? ' dashboard-card--rounded' : '')])->except(['type', 'background', 'backgroundGradient', 'number', 'title', 'icon', 'subText', 'meta', 'trend', 'layout', 'iconBg', 'items', 'rounded']) }} style="{{ $bgStyle }}" > @if($isList) {{-- List / distribution layout --}}
@foreach($items as $item) @php $rowLabel = is_array($item) ? ($item['label'] ?? $item['text'] ?? '') : $item; $rowValue = is_array($item) ? ($item['value'] ?? null) : null; $rowIcon = is_array($item) ? ($item['icon'] ?? null) : null; $isHeader = is_array($item) && ($item['header'] ?? false) || (empty($rowValue) && !empty($rowLabel)); @endphp
@if($rowIcon) @endif {{ $rowLabel }}
@if($rowValue !== null && $rowValue !== '')
{{ $rowValue }}
@endif
@endforeach
@else @if($layout === 'hero')
@if($icon) @endif @if($meta !== null && $meta !== '') {{ $meta }} @endif
@if($number !== null && $number !== '')
{{ $number }}
@endif @if($title !== '')
{{ $title }}
@endif @if($trend !== null && $trend !== '')
{{ $trend }}
@endif @if($subText !== null && $subText !== '')
{{ $subText }}
@endif
@else
@if($icon) @endif
@if($number !== null && $number !== '')
{{ $number }}
@endif @if($title !== '')
{{ $title }}
@endif @if($subText !== null && $subText !== '')
{{ $subText }}
@endif
@endif @endif {{-- Optional extra content (footer, custom block) --}} @if(isset($extra))
{{ $extra }}
@endif