1. Configure the. env file
db_host_trailer=127.0.0.1
db_port_trailer=3306
Db_database_trailer=htms_trailer
Db_username_trailer=root
Db_password_trailer=
db_host_freight=127.0.0.1
db_port_freight=3306
Db_database_freight=hangli_saas
Db_username_freight=root
db_password_freight=
2, Configuration config/database.php
' Mysql_freight ' = [' driver ' = ' mysql ', ' host ' = ' env ' (' db_host_freight ', ' Localho St '), ' database ' = env (' db_database_freight ', ' Forge '), ' username ' = env (' Db_username_frei GHT ', ' Forge '), ' password ' = env (' db_password_freight ', '), ' charset ' = ' utf8 ', ' Collation ' = ' utf8_unicode_ci ', ' prefix ' = ', ' strict ' and ' = False, ' E Ngine ' = null,], ' mysql_trailer ' = [' driver ' = ' mysql ', ' host ' = env (' db_host_trailer ', ' localhost '), ' database ' = env (' Db_database_trailer ', ' Forge '), ' Username ' = env (' Db_username_trailer ', ' Forge '), ' password ' = env (' Db_password_trailer ', '), ' CharSet ' = ' utf8 ', ' collation ' and ' utf8_unicode_ci ', ' prefix ' = ', ' ' Strict ' = False, ' engine ' = null,],
3. Modify Model
$connection ' Mysql_freight ';
Connect multiple databases using the eloquent model of the LARAVEL framework