$file, 'is_file' => is_file($path.'/'.$file), 'meta' => [ 'updated_at' => \Carbon\Carbon::parse($meta['mtime'])->format('d.m.Y h:m:i') ] ]; if ($result['is_file']) { $result['size'] = $this->formatBytes($meta['size']); } $results[] = $result; } return $results; } /** * * @param [type] $size [description] * @param integer $precision [description] * @return [type] [description] */ private function formatBytes($size, $precision = 1) { if ($size === 0) { return '0 bytes'; } $base = log($size, 1024); $suffixes = array('bytes', 'kB', 'MB', 'G', 'T'); return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; } }