@props(['message']) @php $fileExtension = pathinfo($message->file_name, PATHINFO_EXTENSION); $isImage = in_array(strtolower($fileExtension), ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg']); $isVideo = in_array(strtolower($fileExtension), ['mp4', 'webm', 'ogg', 'avi', 'mov']); $isPdf = strtolower($fileExtension) === 'pdf'; $isDocument = in_array(strtolower($fileExtension), ['doc', 'docx', 'txt', 'rtf']); $isSpreadsheet = in_array(strtolower($fileExtension), ['xls', 'xlsx', 'csv']); $isPresentation = in_array(strtolower($fileExtension), ['ppt', 'pptx']); $isArchive = in_array(strtolower($fileExtension), ['zip', 'rar', '7z', 'tar', 'gz']); $fileIcon = 'fas fa-file'; $iconColor = 'text-gray-600'; $bgColor = 'bg-gray-100'; if ($isImage) { $fileIcon = 'fas fa-image'; $iconColor = 'text-green-600'; $bgColor = 'bg-green-100'; } elseif ($isVideo) { $fileIcon = 'fas fa-video'; $iconColor = 'text-red-600'; $bgColor = 'bg-red-100'; } elseif ($isPdf) { $fileIcon = 'fas fa-file-pdf'; $iconColor = 'text-red-600'; $bgColor = 'bg-red-100'; } elseif ($isDocument) { $fileIcon = 'fas fa-file-word'; $iconColor = 'text-blue-600'; $bgColor = 'bg-blue-100'; } elseif ($isSpreadsheet) { $fileIcon = 'fas fa-file-excel'; $iconColor = 'text-green-600'; $bgColor = 'bg-green-100'; } elseif ($isPresentation) { $fileIcon = 'fas fa-file-powerpoint'; $iconColor = 'text-orange-600'; $bgColor = 'bg-orange-100'; } elseif ($isArchive) { $fileIcon = 'fas fa-file-archive'; $iconColor = 'text-purple-600'; $bgColor = 'bg-purple-100'; } $fileSize = $message->file_size; $fileSizeFormatted = ''; if ($fileSize < 1024) { $fileSizeFormatted = $fileSize . ' B'; } elseif ($fileSize < 1024 * 1024) { $fileSizeFormatted = round($fileSize / 1024, 1) . ' KB'; } elseif ($fileSize < 1024 * 1024 * 1024) { $fileSizeFormatted = round($fileSize / (1024 * 1024), 1) . ' MB'; } else { $fileSizeFormatted = round($fileSize / (1024 * 1024 * 1024), 1) . ' GB'; } @endphp