<?php
namespace App\Controller;
use App\Repository\ClientsRepository;
use App\Repository\InvoicesRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DashboardController extends AbstractController
{
private InvoicesRepository $invoicesRepository;
private ClientsRepository $clientsRepository;
public function __construct(
InvoicesRepository $invoicesRepository,
ClientsRepository $clientsRepository
) {
$this->invoicesRepository = $invoicesRepository;
$this->clientsRepository = $clientsRepository;
}
/**
* @Route("/", name="dashboard")
*/
public function index(): Response
{
return $this->render('dashboard/index.html.twig', [
'controller_name' => 'DahsboardController',
'totalInvoicesAmount' => $this->invoicesRepository->getSumOfInvoicesForCurrentMonth(),
'clientsNo' => $this->clientsRepository->getCountClients(),
'notPaidInvoicesNo' => $this->invoicesRepository->getNoOfNotPaidInvoices()
]);
}
}