app\widgets\StorageSpace::render PHP Method

render() public method

render
public render ( ) : string
return string
    public function render()
    {
        $args = $this->config;
        $limit = isset($args['limit']) ? $args['limit'] : 5;
        $disks = Config::get('filesystems.disks');
        $list = [];
        $total = [];
        foreach ($disks as $disk => $setting) {
            $scope = function ($query) use($disk) {
                $query->where('disk', $disk);
            };
            $bytes = XeStorage::bytesByMime($scope);
            $counts = XeStorage::countByMime($scope);
            arsort($bytes);
            $list[$disk] = ['bytes' => [], 'count' => [], 'total' => ['bytes' => array_sum($bytes), 'count' => array_sum($counts)]];
            $bytes = array_slice($bytes, 0, $limit);
            $counts = array_intersect_key($counts, $bytes);
            $list[$disk] = array_merge($list[$disk], ['bytes' => $bytes, 'count' => $counts]);
        }
        return View::make('widget.widgets.storageSpace.show', ['list' => array_filter($list, function ($item) {
            return !empty($item['bytes']);
        }), 'total' => $total])->render();
    }