@php
// prefer model comment, otherwise use the matching history comment
$currentComment = !empty($activite->commentaire_motif) ? $activite->commentaire_motif : ($relevantHistory->commentaire ?? null);
// metadata if the comment came from history
$commentFromHistory = empty($activite->commentaire_motif) && isset($relevantHistory) && !empty($relevantHistory->commentaire);
$historyAuthor = $relevantHistory->changer->name ?? $relevantHistory->changed_by ?? null;
$historyAt = isset($relevantHistory->created_at) ? $relevantHistory->created_at->format('Y-m-d H:i') : null;
@endphp
@if(!empty($currentComment))
{{ $currentComment }}
@endif