@php $cell = function (?int $retained, int $size, float $target): array { if ($retained === null) { return ['text' => 'en cours', 'class' => 'text-gray-400']; } if ($size === 0) { return ['text' => '—', 'class' => 'text-gray-400']; } $rate = $retained / $size * 100; $class = match (true) { $rate >= $target => 'bg-success-100 text-success-800 dark:bg-success-500/20 dark:text-success-300', $rate >= $target / 2 => 'bg-warning-100 text-warning-800 dark:bg-warning-500/20 dark:text-warning-300', default => 'bg-danger-100 text-danger-800 dark:bg-danger-500/20 dark:text-danger-300', }; return ['text' => number_format($rate, 0).' % ('.$retained.'/'.$size.')', 'class' => $class]; }; @endphp
@foreach ($cohorts as $cohort) @php($d1 = $cell($cohort['d1'], $cohort['size'], $d1Target)) @php($d7 = $cell($cohort['d7'], $cohort['size'], $d7Target)) @endforeach
Inscrits le Inscrits J1 (objectif {{ rtrim(rtrim(number_format($d1Target, 1, ',', ''), '0'), ',') }} %) J7 (objectif {{ rtrim(rtrim(number_format($d7Target, 1, ',', ''), '0'), ',') }} %)
{{ \Illuminate\Support\Carbon::parse($cohort['date'])->translatedFormat('D d/m') }} {{ $cohort['size'] }} {{ $d1['text'] }} {{ $d7['text'] }}