@php
// prefer the model's comment; otherwise use the most recent matching history comment
$modelComment = $immobilier->commentaire_motif ?? null;
$currentComment = !empty($modelComment) ? $modelComment : ($relevantHistory->commentaire ?? null);
$commentFromHistory = empty($modelComment) && 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))
{{ __('site.start_activity.current_comment') }}
{{ $currentComment }}
@if($commentFromHistory && ($historyAuthor || $historyAt))
@if($historyAuthor) {{ $historyAuthor }} @endif
@if($historyAuthor && $historyAt) — @endif
@if($historyAt) {{ $historyAt }} @endif
@endif
@endif