mime_type); switch ($type) { case 'image': $url = Template::thumbnail($file->filename); return '' . $file->description . ''; break; case 'text': return self::getIcon($file, 'fa-file-text-o'); break; case 'application': switch ($subtype) { case 'pdf': return self::getIcon($file, 'fa-file-pdf-o'); break; default: return self::getIcon($file, 'fa-newspaper-o'); break; } break; default: return self::getIcon($file, 'fa-question'); break; } } /** * Shortcut for displaying icons * * @param $file * @param $icon * * @return string */ protected static function getIcon($file, $icon) { return '


' . e(str_limit($file->original_filename, 15)) . '

'; } /** * * * @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]); } /** * Get preview for file detail * * @param File $file * * @return \Illuminate\Contracts\Routing\UrlGenerator|string */ public static function getLargePreview(File $file) { list($type, $subtype) = explode('/', $file->mime_type); $url = config('app.upload_url') . '/' . $file->filename; $path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename; switch ($type) { case 'image': return '' . $file->description . ''; break; case 'text': $string = '
';
                $string .= htmlspecialchars(file_get_contents($path));
                $string .= '
'; return $string; break; case 'application': return ''; break; default: return self::getPreview($file); break; } } /** * @param File $file * * @return array */ public static function getAdditionalInfo(File $file) { list($type, $subtype) = explode('/', $file->mime_type); $path = config('app.upload_path') . DIRECTORY_SEPARATOR . $file->filename; switch ($type) { case 'text': return [trans('admin/fileManager.encoding') => mb_detect_encoding(file_get_contents($path))]; break; case 'image': list ($width, $height) = getimagesize($path); return [trans('admin/fileManager.resolution') => $height . ' x ' . $width,]; break; } return []; } }