mime_type); switch ($type) { case 'image': // try to check if file have thumbnail if (file_exists(config('app.thumbnail_url') . '/' . $file->filename)) { $url = config('app.thumbnail_url') . '/' . $file->filename; } else { $url = config('app.upload_url') . '/' . $file->filename; } return '' . $file->description . ''; break; case 'text': return ''; break; case 'application': switch ($subtype) { case 'pdf': return ''; break; default: return ''; break; } break; default: return ''; break; } } /** * * * @param File $file * * @return string */ public static function getFormattedSize(File $file) { $bytes = $file->file_size; $label = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; for ($i = 0; $bytes >= 1024 && $i < (count($label) - 1); $bytes /= 1024, $i++) { ; } return (round($bytes, 2) . " " . $label[$i]); } }