Obtain Database Names of Multiple Connections in Laravel

To get database name from any connections we have to assign DB::connection name and call getDatabaseName() to get database name.

in App\config\database.php

in .env

in model.php

output