Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 diffrent Dashboards always going to "/admin" #6580

Closed
ben29 opened this issue Nov 26, 2024 · 0 comments
Closed

2 diffrent Dashboards always going to "/admin" #6580

ben29 opened this issue Nov 26, 2024 · 0 comments

Comments

@ben29
Copy link

ben29 commented Nov 26, 2024

Hi.
since using Pretty URLs, I have issue with the dashboards.

config/routes/easyadmin.yaml:

easyadmin:
    resource: .
    type: easyadmin.routes

I create 2 diffrent dashboards.

admin:

<?php

namespace App\Controller\Admin;

use App\Entity\Order;
use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class AdminDashboardController extends AbstractDashboardController
{
    #[Route('/admin', name: 'admin')]
    public function index(): Response
    {
        return $this->render('admin/index.html.twig');
    }

    public function configureDashboard(): Dashboard
    {
        return Dashboard::new()
            ->setTitle('Demo');
    }

    public function configureMenuItems(): iterable
    {
        yield MenuItem::linkToDashboard('Dashboard', 'fa6-solid:house');
        yield MenuItem::linkToCrud('Users', 'fas fa-list', User::class);
        yield MenuItem::linkToCrud('Orders', 'fas fa-list', Order::class);
    }
}

aff:


<?php

namespace App\Controller\Aff;

use App\Entity\User;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class AffDashboardController extends AbstractDashboardController
{
    #[Route('/aff', name: 'aff')]
    public function index(): Response
    {
        return $this->render('admin/index.html.twig');
    }

    public function configureDashboard(): Dashboard
    {
        return Dashboard::new()
            ->setTitle('Demo');
    }

    public function configureMenuItems(): iterable
    {
        yield MenuItem::linkToDashboard('Dashboard', 'fa6-solid:house');
        yield MenuItem::linkToCrud('Users', 'fas fa-list', User::class);
    }
}

when I go to https://127.0.0.1:8000/aff it shows the current aff dashboard. which is ok!

but when I hit for example to Users.

it's goes to admin dashboard with all the links

I found that the links on the menu always is "/admin". but my aff dashboard is '/aff'

and after I click "Users" it's change to AdminDashboard, with all the urls and menus.

Screenshot 2024-11-26 at 21 48 18

adding:

#[AdminDashboard]

fix the urls issue.

but the major problem, when I click one of the Dashboard item, it will show after that the 'admin' menu

@ben29 ben29 changed the title 2 diffrent Dashboards always going to "admin" 2 diffrent Dashboards always going to "/admin" Nov 27, 2024
@ben29 ben29 closed this as completed Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant