Naming conflicts

This is the official documentation of the forestadmin/laravel-forestadmin v2+ and forestadmin/symfony-forestadmin PHP agents.

When importing collections to an admin panel, you may encounter naming collisions.

You can tackle them by renaming the collection that is causing issues.

There are two ways to rename collections: either provide a plain object which maps the old names to the new names, or a function which does the same.

Don't worry about leaving naming collisions: your development agent will warn you and crash at startup.

use ForestAdmin\AgentPHP\Agent\Utils\Env;
use ForestAdmin\AgentPHP\DatasourceDoctrine\DoctrineDatasource;
use ForestAdmin\SymfonyForestAdmin\Service\ForestAgent;

return static function (ForestAgent $forestAgent) {
    // Rename the `customers` and `stores` collections.
    // Note that other collections won't be renamed.
    $forestAgent->addDatasource(
        new DoctrineDatasource(
            $forestAgent->getEntityManager(),
            ['url' => Env::get('DATABASE_URL')]
        ),
        [
            'rename' => [
                'Customer' => 'CustomerFromDoctrine',
                'Store' => 'StoreFromDoctrine',
            ],
        ]
    )
        ->build();
};

Last updated