This is an example of Laravel with multiple database connections for operating Eloquent Relationship and join query.
There are three connections:
mysql
(MySQL) as defaultmysql2
(MySQL)sqlsrv
(SQL Server 2016)
git clone https://github.com/didikz/laravel-multidb.git
composer install
Copy .env.example as .env file and setup your database configuration. If you don't have SQL server, feel free to use another database engine but don't forget to adjust your new connection.
php artisan key:generate
php artisan migrate
php artisan db:seed --class=IsiTableSeeder
php artisan serve
Visit your browser to http://localhost:8000/publishing
to get data from multiple database connections. Open routes/web.php
to check available routes;
There are three migration tables with different connection:
types
table / model inmysql2
connectionposts
table / model inmysql
connectionmails
table / model insqlsrv
connection
Edit your migration & model connection if you used different connection.