<?php

namespace Vanguard\Support\Plugins\Dashboard\Widgets;

use Illuminate\Contracts\View\View;
use Vanguard\Plugins\Widget;
use Vanguard\Repositories\User\UserRepository;

class NewUsers extends Widget
{
    /**
     * {@inheritdoc}
     */
    public ?string $width = '3';

    /**
     * {@inheritdoc}
     */
    protected string|\Closure|array $permissions = 'users.manage';

    public function __construct(protected readonly UserRepository $users)
    {
    }

    /**
     * {@inheritdoc}
     */ 

    public function render(): View
{
    return view('plugins.dashboard.widgets.new-users', [
        'count' => \Illuminate\Support\Facades\DB::table('communities')
            // Correct way to check if 'created_at' is equal to the current date.
            ->whereDate('created_at', today()) 
            ->count(),
    ]);
}
}
