src/Controller/Admin/DashboardController.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Entity\Adressen;
  4. use App\Entity\City;
  5. use App\Entity\DeliveryRequest;
  6. use App\Entity\Driver;
  7. use App\Entity\KeyToAccess;
  8. use App\Entity\OrderGermany;
  9. use App\Entity\OrderUkraine;
  10. use App\Entity\Routers;
  11. use App\Entity\User;
  12. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  13. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  14. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\Security\Core\Security;
  18. class DashboardController extends AbstractDashboardController
  19. {
  20.     private $security;
  21.     public function __construct(Security $security)
  22.     {
  23.         $this->security $security;
  24.     }
  25.     #[Route('/admin'name'admin')]
  26.     public function index(): Response
  27.     {
  28.         //return parent::index();
  29.         // Option 1. You can make your dashboard redirect to some common page of your backend
  30.         //
  31.         // $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class);
  32.         // return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl());
  33.         // Option 2. You can make your dashboard redirect to different pages depending on the user
  34.         //
  35.         // if ('jane' === $this->getUser()->getUsername()) {
  36.         //     return $this->redirect('...');
  37.         // }
  38.         // Option 3. You can render some custom template to display a proper dashboard with widgets, etc.
  39.         // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig)
  40.         //
  41.         // return $this->render('some/path/my-dashboard.html.twig');
  42.         return $this->render('admin/my-dashboard.html.twig');
  43.     }
  44.     public function configureDashboard(): Dashboard
  45.     {
  46.         return Dashboard::new()
  47.             // the name visible to end users
  48.             ->setTitle('Доставка')
  49.             // you can include HTML contents too (e.g. to link to an image)
  50.             ->setTitle('<img src="..."> Доставка <span class="text-small">Админка.</span>')
  51.             // by default EasyAdmin displays a black square as its default favicon;
  52.             // use this method to display a custom favicon: the given path is passed
  53.             // "as is" to the Twig asset() function:
  54.             // <link rel="shortcut icon" href="{{ asset('...') }}">
  55.             ->setFaviconPath('favicon.svg')
  56.             // the domain used by default is 'messages'
  57.             ->setTranslationDomain('my-custom-domain')
  58.             // there's no need to define the "text direction" explicitly because
  59.             // its default value is inferred dynamically from the user locale
  60.             ->setTextDirection('ltr')
  61.             // set this option if you prefer the page content to span the entire
  62.             // browser width, instead of the default design which sets a max width
  63.             ->renderContentMaximized()
  64.             // set this option if you prefer the sidebar (which contains the main menu)
  65.             // to be displayed as a narrow column instead of the default expanded design
  66.             ->renderSidebarMinimized()
  67.             // by default, users can select between a "light" and "dark" mode for the
  68.             // backend interface. Call this method if you prefer to disable the "dark"
  69.             // mode for any reason (e.g. if your interface customizations are not ready for it)
  70.             ->disableDarkMode()
  71.             // by default, all backend URLs are generated as absolute URLs. If you
  72.             // need to generate relative URLs instead, call this method
  73.             ->generateRelativeUrls()
  74.             // set this option if you want to enable locale switching in dashboard.
  75.             // IMPORTANT: this feature won't work unless you add the {_locale}
  76.             // parameter in the admin dashboard URL (e.g. '/admin/{_locale}').
  77.             // the name of each locale will be rendered in that locale
  78.             // (in the following example you'll see: "English", "Polski")
  79.             ->setLocales(['en''pl'])
  80.             // to customize the labels of locales, pass a key => value array
  81.             // (e.g. to display flags; although it's not a recommended practice,
  82.             // because many languages/locales are not associated to a single country)
  83.             ->setLocales([
  84.                 'en' => '🇬🇧 English',
  85.                 'pl' => '🇵🇱 Polski'
  86.             ])
  87.             // to further customize the locale option, pass an instance of
  88.             // EasyCorp\Bundle\EasyAdminBundle\Config\Locale
  89.             ->setLocales([
  90.                 'en'// locale without custom options
  91.             ])
  92.             ;
  93.     }
  94.     public function configureMenuItems(): iterable
  95.     {
  96.         yield MenuItem::linkToDashboard('Головна''fa fa-home');
  97.        // yield MenuItem::linkToCrud('Посики з Украины', 'fa fa-home', OrderUkraine::class);
  98.         if ($this->security->isGranted('ROLE_ADMIN_UKRAINE')) {
  99.              yield MenuItem::linkToRoute('Скан''fa fa-home'"admin_scan");
  100.              yield MenuItem::linkToRoute('Пошук''fa fa-home'"admin_search");
  101.             yield MenuItem::linkToCrud('Актуальні''fa fa-home'OrderUkraine::class)
  102.                 ->setController(OrderUkraineCrudController::class);
  103.             yield MenuItem::linkToCrud('В Німеччині''fa fa-home'OrderUkraine::class)
  104.                 ->setController(OrderUkraineCrudDeliveredController::class);
  105.         }
  106.       if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {
  107.           yield MenuItem::section('Посилки з україни');
  108.           yield MenuItem::linkToCrud('Актуальні''fa fa-home'OrderUkraine::class)
  109.               ->setController(OrderUkraineCrudController::class);
  110.     yield MenuItem::linkToCrud('В Німеччині''fa fa-home'OrderUkraine::class)
  111.         ->setController(OrderUkraineCrudDeliveredController::class);
  112.           yield MenuItem::linkToCrud('Відгружені (Архів)''fa fa-home'OrderUkraine::class)
  113.         ->setController(OrderUkraineOldCrudController::class);
  114.           yield MenuItem::linkToCrud('На складі (Архів)''fa fa-home'OrderUkraine::class)
  115.               ->setController(OrderUkraineSkladCrudController::class);
  116.           yield MenuItem::linkToCrud('Замовлення доставки''fa fa-home'DeliveryRequest::class);
  117.           yield MenuItem::linkToCrud('Міста''fa fa-home'City::class);
  118.           yield MenuItem::linkToCrud('Ключі''fa fa-home'KeyToAccess::class);
  119.           yield MenuItem::linkToCrud('Водії''fa fa-home'Driver::class);
  120.           yield MenuItem::linkToCrud('Адреса видачі''fa fa-home'Adressen::class);
  121.           yield MenuItem::linkToCrud('Маршрути''fa fa-home'Routers::class);
  122.           yield MenuItem::linkToCrud('Користувачі''fa fa-home'User::class);
  123.          yield MenuItem::linkToRoute('Роздрукувати у німетчині адмін ''fa fa-print''pdf_generate2')
  124.     ->setLinkTarget('_blank');
  125.     
  126.          yield MenuItem::linkToRoute('Роздрукувати у німетчині''fa fa-print''pdf_generate_driver')
  127.     ->setLinkTarget('_blank');
  128.           yield MenuItem::linkToRoute('Роздрукувати актуальні''fa fa-print''pdf_ggenerateAktual')
  129.               ->setLinkTarget('_blank');
  130.           yield MenuItem::linkToRoute('Роздрукувати склад''fa fa-print''pdf_generateSklad')
  131.               ->setLinkTarget('_blank');
  132.     // Добавьте другие элементы меню для ROLE_SUPER_ADMIN, если нужно
  133. }
  134.         /* yield MenuItem::linkToCrud('Посики з України', 'fa fa-home');
  135.          yield MenuItem::linkToCrud('Користувачі', 'fa fa-home');*/
  136.         // yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class);
  137.     }
  138. }