@php $backgroundPath = null; $mimeType = 'image/png'; if ($team->backgroundImage) { // DB 保存される url は "/storage/img/xxx.png" などの公開 URL 形式のため、 // ディスク上の実ファイルパスを得るには /storage プレフィックスを除いた // ディスク相対パスへ正しく変換する必要がある。 $diskPath = \App\Models\File::resolveDiskPath($team->backgroundImage->url); if (! empty($diskPath)) { $candidatePath = storage_path('app/public/' . ltrim($diskPath, '/')); if (file_exists($candidatePath)) { $backgroundPath = $candidatePath; $mimeType = $team->backgroundImage->media_type ?? 'image/png'; } } // s3_key には "img/xxx.png" 形式のディスク相対パスが入っているため、 // 上記で解決できなかった場合のフォールバックとして利用する。 if ($backgroundPath === null && ! empty($team->backgroundImage->s3_key)) { $candidatePath = storage_path('app/public/' . ltrim($team->backgroundImage->s3_key, '/')); if (file_exists($candidatePath)) { $backgroundPath = $candidatePath; $mimeType = $team->backgroundImage->media_type ?? 'image/png'; } } } if ($backgroundPath === null) { $defaultPath = public_path('/img/certificate_' . $direction . '.png'); if (file_exists($defaultPath)) { $backgroundPath = $defaultPath; $mimeType = 'image/png'; } } if ($backgroundPath !== null && file_exists($backgroundPath)) { $backgroundData = base64_encode(file_get_contents($backgroundPath)); $background = 'data:' . $mimeType . ';base64,' . $backgroundData; } else { $background = ''; } @endphp {!! __("team-certificate.certificate.title") !!}
{!! __("team-certificate.certificate.title") !!}
{!! __("team-certificate.certificate.prefix") !!} {{ $user->name }} {!! __("team-certificate.certificate.postfix") !!} @if ($user->team->registration_number_name) ({{ $user->team->registration_number_name }}: {{ $user->registration_number ?? '未登録' }}) @endif
{!! str_replace('{$team}', $team->name, str_replace('{$quiz}', $quizResult->survey->name, $team->certificate_text)) !!}

{{ $quizResult->start_at ? $quizResult->start_at->format('Y.m.d'): date("Y.m.d") }} {{ $team->leader_title }} {{ $team->leader }}