At-Risk Customers

@php try { // Use cached viewData from component $viewDataForTotal = $viewData ?? $this->getViewData(); echo $viewDataForTotal['total'] ?? 0; } catch (\Exception $e) { echo 0; } @endphp total
@php try { // Use cached viewData from component $data = $viewData ?? $this->getViewData(); $customers = $data['customers'] ?? []; $pagination = [ 'total' => $data['total'] ?? 0, 'per_page' => $data['per_page'] ?? 10, 'current_page' => $data['current_page'] ?? 1, 'total_pages' => $data['total_pages'] ?? 1, 'from' => $data['from'] ?? 0, 'to' => $data['to'] ?? 0, ]; } catch (\Exception $e) { \Illuminate\Support\Facades\Log::error('AtRiskCustomersWidget view error: ' . $e->getMessage()); $customers = []; $pagination = [ 'total' => 0, 'per_page' => 10, 'current_page' => 1, 'total_pages' => 1, 'from' => 0, 'to' => 0, ]; } @endphp @if(empty($customers))

No at-risk customers found.

@else @foreach($customers as $index => $customer) @php $riskScoreRaw = $customer['risk_score_raw'] ?? (int) str_replace('%', '', $customer['risk_score']); @endphp @endforeach
Customer Plan Risk Level Last Payment Risk Score Actions
{{ strtoupper(substr($customer['customer'], 0, 1)) }}
{{ $customer['customer'] }}
ID: {{ $customer['id'] }}
@php $planClass = match(strtolower($customer['plan'])) { 'enterprise' => 'plan-enterprise', 'premium' => 'plan-premium', 'basic' => 'plan-basic', default => 'plan-default', }; @endphp {{ $customer['plan'] }} @php $riskLevelClass = match(strtolower($customer['risk_level'])) { 'high' => 'risk-high', 'medium' => 'risk-medium', default => 'risk-low', }; @endphp @if($customer['risk_level'] === 'High') @elseif($customer['risk_level'] === 'Medium') @else @endif {{ $customer['risk_level'] }} @if($customer['last_payment'] === 'Never')
Never
@else
{{ \Carbon\Carbon::parse($customer['last_payment'])->format('Y-m-d') }}
@endif
@php $riskScoreClass = match(true) { $riskScoreRaw >= 80 => 'score-critical', $riskScoreRaw >= 60 => 'score-high', $riskScoreRaw >= 40 => 'score-medium', default => 'score-low', }; @endphp
{{ $customer['risk_score'] }}
@endif