<?php

namespace App\Filament\Widgets;

use App\Models\Course;
use App\Models\Guide;
use Filament\Widgets\Widget;

class TopContent extends Widget
{
    protected string $view = 'filament.widgets.top-content';

    protected int|string|array $columnSpan = 'full';

    protected static ?int $sort = 1;

    protected static bool $isLazy = false;

    public function getViewData(): array
    {
        return [
            'guides' => Guide::orderByDesc('download_count')->limit(5)->get(),
            'courses' => Course::withCount('enrollments')->orderByDesc('enrollments_count')->limit(5)->get(),
        ];
    }
}
