<?php

namespace App\Filament\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use App\Models\User;
use App\Models\Word;

class StatsOverview extends BaseWidget
{
    protected function getStats(): array
    {
             $totalUsers = User::count();
              $totalWords = Word::count();

        $newUsers = User::where('created_at', '>=', now()->subDays(7))->count();
       $newWords = Word::where('created_at', '>=', now()->subDays(7))->count();

        return [
                Stat::make('Total Words', number_format($totalWords))
                ->description(number_format($newWords) . ' new added')
                ->descriptionIcon('heroicon-m-arrow-trending-up')
                ->color('success'),

            Stat::make('Total Users', number_format($totalUsers))
                ->description(number_format($newUsers) . ' new users')
                   ->chart([7, 2, 10, 3, 15, 4, 17])
                ->descriptionIcon('heroicon-m-arrow-trending-up')
                ->color('success'),
        ];
    } 
}
