@php /** * Shared star-rating partial. * * Renders full / half / empty stars reflecting the REAL numeric rating, using * Font Awesome 5.11.2 glyphs (fas fa-star / fas fa-star-half-alt / far fa-star). * The visual row is aria-hidden; a visually-hidden "X out of 5" gives the * accessible name. Replaces the fake fixed-5-solid-star loops across the app. * * @var float|int|string $rate Rating 0–5 (defaults to 0 if not provided). * @var string $size Optional: '', 'sm', or 'lg' → .qm-stars-{size}. * * Usage: * partial('cards/stars', ['rate' => $r['rating_cache']]); * partial('cards/stars', ['rate' => 4.5, 'size' => 'lg']); */ $rate = isset($rate) ? (float) $rate : 0.0; if ($rate < 0) { $rate = 0.0; } if ($rate > 5) { $rate = 5.0; } $size = isset($size) && $size !== '' ? ' qm-stars-' . preg_replace('/[^a-z]/', '', strtolower($size)) : ''; $full = (int) floor($rate); $half = ($rate - $full) >= 0.5 ? 1 : 0; $empty = 5 - $full - $half; $display = rtrim(rtrim(number_format($rate, 1), '0'), '.'); @endphp {{ t_raw('common.rating_out_of_5', [':rate' => $display]) }}