src/Application/Controller/App/Admin/DashboardController.php line 40

Open in your IDE?
  1. <?php
  2. namespace BackendApi\Application\Controller\App\Admin;
  3. use BackendApi\Domain\Machine\Machine;
  4. use BackendApi\Domain\Machine\Notification;
  5. use BackendApi\Domain\Machine\ServiceHistory;
  6. use BackendApi\Domain\Security\Account;
  7. use BackendApi\Infrastructure\DoctrineAccounts;
  8. use BackendApi\Infrastructure\DoctrineMachines;
  9. use BackendApi\Infrastructure\DoctrineServiceHistories;
  10. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  11. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  12. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. class DashboardController extends AbstractDashboardController
  16. {
  17.     private DoctrineMachines $doctrineMachines;
  18.     private DoctrineServiceHistories $doctrineServiceHistories;
  19.     private DoctrineAccounts $doctrineAccounts;
  20.     public function __construct(
  21.         DoctrineMachines $doctrineMachines,
  22.         DoctrineServiceHistories $doctrineServiceHistories,
  23.         DoctrineAccounts $doctrineAccounts
  24.     )
  25.     {
  26.         $this->doctrineMachines $doctrineMachines;
  27.         $this->doctrineServiceHistories $doctrineServiceHistories;
  28.         $this->doctrineAccounts $doctrineAccounts;
  29.     }
  30.     /**
  31.      * @Route("/admin", name="app_admin")
  32.      */
  33.     public function index(): Response
  34.     {
  35.         return $this->render('admin/dashboard.html.twig', [
  36.             'machinesCount' => $this->doctrineMachines->getMachinesCount(),
  37.             'serviceHistoriesCount' => $this->doctrineServiceHistories->allServiceHistoriesCount(),
  38.             'activeAccountsCount' => $this->doctrineAccounts->allActiveAccountsCount(),
  39.         ]);
  40.     }
  41.     public function configureDashboard(): Dashboard
  42.     {
  43.         return Dashboard::new()
  44.             ->setTitle('Baume Admin')
  45.             ->setFaviconPath('assets/images/favicon.png');
  46.     }
  47.     public function configureMenuItems(): iterable
  48.     {
  49.         return [
  50.             MenuItem::linkToDashboard('Dashboard''fa fa-home'),
  51.             MenuItem::linkToCrud('Maszyny''fa fa-gears'Machine::class),
  52.             MenuItem::linkToCrud('Historia serwisowa''fa fa-screwdriver-wrench'ServiceHistory::class),
  53.             MenuItem::linkToCrud('Przypomnienia''fa fa-bell'Notification::class),
  54.             MenuItem::linkToCrud('Użytkownicy''fa fa-users'Account::class),
  55.         ];
  56.     }
  57. }