@php $generatedContent = cache('generated_content'); $all = $generatedContent->count(); $all = $all == 0 ? 1 : $all; $contents = [ [ 'type' => 'text', 'label' => 'Text', 'color' => '#3C82F6', 'percent' => round(($generatedContent->filter(fn($entity) => $entity->generator?->type == 'text')->count() / $all) * 100, 0), ], [ 'type' => 'image', 'label' => 'Image', 'color' => '#9F77F8', 'percent' => round(($generatedContent->filter(fn($entity) => $entity->generator?->type == 'image')->count() / $all) * 100, 0), ], [ 'type' => 'audio', 'label' => 'Audio', 'color' => '#60A5FA', 'percent' => round(($generatedContent->filter(fn($entity) => $entity->generator?->type == 'audio')->count() / $all) * 100, 0), ], [ 'type' => 'video', 'label' => 'Video', 'color' => '#20C69F', 'percent' => round(($generatedContent->filter(fn($entity) => $entity->generator?->type == 'video')->count() / $all) * 100, 0), ], [ 'type' => 'code', 'label' => 'Code', 'color' => '#E0B43E', 'percent' => round(($generatedContent->filter(fn($entity) => $entity->generator?->type == 'code')->count() / $all) * 100, 0), ], ]; /** * sort the content using percent * @param array $contents */ usort($contents, function ($a, $b) { return $a['percent'] < $b['percent']; }); @endphp

{{ __('Generated Content') }}

@foreach ($contents as $content) @if ($content['percent'] != 0) @endif @endforeach