protected function prepareRatios(Collection $tags)
    {
        $ratios = $tags->filter(function (Tag $tag) {
                return $tag->hasPosts();
            })
            ->transform(function (Tag $tag) {
                return [
                    'label' => $tag->name,
                    'posts' => $tag->posts->count(),
                ];
            })
            ->sortByDesc('posts');

        $chunk  = $ratios->splice(5);
        $ratios = $this->colorizeRatios($ratios);

        return $chunk->isEmpty() ? $ratios : $ratios->push([
            'label' => 'Other Tags',
            'posts' => $chunk->sum('posts'),
            'color' => '#D2D6DE',
        ]);
    }
protected function prepareRatios(Collection $tags)
    {
        $ratios = $tags->filter(function (Tag $tag) {
                return $tag->hasPosts();
            })
            ->transform(function (Tag $tag) {
                return [
                    'label' => $tag->name,
                    'posts' => $tag->posts->count(),
                ];
            })
            ->sortByDesc('posts');

        $chunk  = $ratios->splice(5);
        $ratios = $this->colorizeRatios($ratios);

        return $chunk->isEmpty() ? $ratios : $ratios->push([
            'label' => 'Other Tags',
            'posts' => $chunk->sum('posts'),
            'color' => '#D2D6DE',
        ]);
    }
protected function prepareRatios ( Collection $ tags ) { $ ratios = $ tags -> filter ( function ( Tag $ tag ) { return $ tag -> hasPosts ( ) ; } ) -> transform ( function ( Tag $ tag ) { return [ 'label' => $ tag -> name , 'posts' => $ tag -> posts -> count ( ) , ] ; } ) -> sortByDesc ( 'posts' ) ; $ chunk = $ ratios -> splice ( 5 ) ; $ ratios = $ this -> colorizeRatios ( $ ratios ) ; return $ chunk -> isEmpty ( ) ? $ ratios : $ ratios -> push ( [ 'label' => 'Other Tags' , 'posts' => $ chunk -> sum ( 'posts' ) , 'color' => '#D2D6DE' , ] ) ; }
Prepare the tags ratios.

@param  \Illuminate\Database\Eloquent\Collection  $tags

@return \Illuminate\Database\Eloquent\Collection
Prepare the tags ratios .