@if($msg->message)
{{ $msg->message }}
@endif
@if($msg->file_path)
@php
$isImage = Str::startsWith($msg->file_type, 'image');
$isVideo = Str::startsWith($msg->file_type, 'video');
$isPdf = Str::endsWith($msg->file_path, '.pdf');
$isDocument = in_array(Str::lower(Str::afterLast($msg->file_path, '.')), ['doc', 'docx', 'txt']);
$fileName = basename($msg->file_path);
// Get file size from storage if possible
$fileSize = 'N/A';
try {
$fullPath = storage_path('app/public/' . $msg->file_path);
if (file_exists($fullPath)) {
$size = filesize($fullPath);
if ($size < 1024) {
$fileSize = $size . ' B';
} elseif ($size < 1048576) {
$fileSize = round($size / 1024, 1) . ' KB';
} else {
$fileSize = round($size / 1048576, 1) . ' MB';
}
}
} catch (Exception $e) {
$fileSize = 'Unknown';
}
// Determine file class
if ($isImage) {
$fileClass = 'image-file';
$fileIcon = 'πΌοΈ';
} elseif ($isVideo) {
$fileClass = 'video-file';
$fileIcon = 'π¬';
} elseif ($isPdf) {
$fileClass = 'pdf-file';
$fileIcon = 'π';
} elseif ($isDocument) {
$fileClass = 'document-file';
$fileIcon = 'π';
} else {
$fileClass = 'other-file';
$fileIcon = 'π';
}
@endphp
@endif
{{ $msg->created_at->format('d M h:i A') }}