@extends('pdf._base')
@section('title', 'Certificate '.$c->credential_id)
@php
$completion = in_array(strtolower((string) $c->type), ['course completion', 'completion'], true);
$name = $c->user->name;
$len = mb_strlen($name);
$nameSize = $len > 30 ? 34 : ($len > 22 ? 40 : 46);
$course = preg_replace('/\s+—\s+(Certificate of Completion|Certificate)$/u', '', $c->title);
$courseSize = mb_strlen($course) > 70 ? 17 : (mb_strlen($course) > 46 ? 20 : 24);
$ev = (array) ($c->evidence ?? []);
$hours = $ev['hours'] ?? $ev['duration_hours'] ?? $c->course?->total_hours;
$pct = $ev['percent'] ?? $c->score;
$att = $ev['attendance_percent'] ?? null;
$fmt = fn ($v) => rtrim(rtrim(number_format((float) $v, 1), '0'), '.');
$facts = array_filter([
$c->course?->exam_code ? ['Aligned to', $c->course->exam_code] : null,
$hours ? ['Training', $fmt($hours).' hours'] : null,
$pct !== null ? ['Assessment', $fmt($pct).'%'] : null,
$att !== null ? ['Attendance', $fmt($att).'%'] : null,
$c->course?->level ? ['Level', $c->course->level] : null,
]);
$skills = $c->skills->pluck('name')->take(6);
$verifyHost = preg_replace('#^https?://#', '', $c->verifyUrl());
@endphp
@section('css')
@endsection
@section('body')
{{-- band --}}