src/Controller/DashboardController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\SubscriptionRepository;
  4. use App\Repository\TransactionRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * @Route("/admin")
  11.  */
  12. class DashboardController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/dashboard", name="app_dashboard")
  16.      */
  17.     public function index(
  18.         TransactionRepository  $transactionRepository,
  19.         SubscriptionRepository $subscriptionRepository,
  20.         Request                $request
  21.     ): Response
  22.     {
  23.         $currency $request->query->get('currency''USD');
  24.         $resume = [
  25.             'total_transaction' => $transactionRepository->count([]),
  26.             'total_modem' => $subscriptionRepository->count([]),
  27.             'period_transaction' => $transactionRepository->period(),
  28.             'paid_not_sent_transaction' => $transactionRepository->count(['step' => 6'paid' => true'sent' => false]),
  29.             'data_yearly_sales' => json_encode($transactionRepository->getDataYearlySales($currency))
  30.         ];
  31.         return $this->render('dashboard/index.html.twig', [
  32.             'dashboard_resume' => $resume,
  33.             'currency' => $currency
  34.         ]);
  35.     }
  36. }