src/Controller/Admin/DashboardController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Results;
  4. use App\Entity\User;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  7. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  8. use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class DashboardController extends AbstractDashboardController
  12. {
  13.     #[Route('/'name'admin')]
  14.     public function index(): Response
  15.     {
  16.         
  17.         $adminUrlGenerator $this->container->get(AdminUrlGenerator::class);
  18.         return $this->redirect($adminUrlGenerator->setController(ResultsCrudController::class)->generateUrl());
  19.         //return parent::index();
  20.         // Option 1. You can make your dashboard redirect to some common page of your backend
  21.         //
  22.         // $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
  23.         // return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl());
  24.         // Option 2. You can make your dashboard redirect to different pages depending on the user
  25.         //
  26.         // if ('jane' === $this->getUser()->getUsername()) {
  27.         //     return $this->redirect('...');
  28.         // }
  29.         // Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
  30.         // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
  31.         //
  32.         // return $this->render('some/path/my-dashboard.html.twig');
  33.     }
  34.     public function configureDashboard(): Dashboard
  35.     {
  36.         return Dashboard::new()
  37.             ->setTitle('<img width="130px" style="margin:10px 0 0 40px;" src="assets/images/logo.png" />')
  38.             ->setTranslationDomain("admin")
  39.             ->setFaviconPath("assets/images/logo.png")
  40.             ->renderSidebarMinimized()
  41.             ;
  42.     }
  43.     public function configureMenuItems(): iterable
  44.     {
  45.         yield MenuItem::linkToDashboard('Results''fa fa-home');
  46.         
  47.         yield MenuItem::linkToCrud('Users''fas fa-user-shield'User::class);
  48.         
  49.         
  50.        
  51.     }
  52. }