I would like to get databases informations stored in my database in the database.php.
I tried to get all infos in the database but I always have an error like this :
[2019-04-18 16:13:16] laravel.ERROR: syntax error, unexpected 'return' (T_RETURN) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): syntax error, unexpected 'return' (T_RETURN) at /var/www/vhosts/xxxxx.net/httpdocs/config/database.php:22)
I added this on the top of database.php :
use App\Campaign;
$database_infos = Campaign::all();
$campains_db = array();
foreach ($database_infos as $info) {
if (isset($info->db_name)) {
$campains_db[$info->keyword] = array(
'driver' => 'mysql',
'host' => $info->db_host,
'database' => $info->db_name,
'username' => $info->db_user,
'password' => decrypt($info->db_password),
'prefix' => $info->db_prefix,
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'strict' => false,
'engine' => null,
);
}
}
And this under :
'connections' => [
$campains_db,
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
];
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire