<?php
namespace App\Controller;
use App\Repository\SubscriptionRepository;
use App\Repository\TransactionRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/admin")
*/
class DashboardController extends AbstractController
{
/**
* @Route("/dashboard", name="app_dashboard")
*/
public function index(
TransactionRepository $transactionRepository,
SubscriptionRepository $subscriptionRepository,
Request $request
): Response
{
$currency = $request->query->get('currency', 'USD');
$resume = [
'total_transaction' => $transactionRepository->count([]),
'total_modem' => $subscriptionRepository->count([]),
'period_transaction' => $transactionRepository->period(),
'paid_not_sent_transaction' => $transactionRepository->count(['step' => 6, 'paid' => true, 'sent' => false]),
'data_yearly_sales' => json_encode($transactionRepository->getDataYearlySales($currency))
];
return $this->render('dashboard/index.html.twig', [
'dashboard_resume' => $resume,
'currency' => $currency
]);
}
}