I have a Laravel project.
I have three databases. the first database is for the current project and I can use migrations.
I know how I can connect to it and use migrations.
Two other databases I should connect to it.
but I want to use Model
instead of using the query.
for example:
in the second database, I have this table:
works
id - title
in the third database, I have this table:
logics
id - title
I want to use Work::first()
or Logic::get()
in current my Laravel project;
What can I do?
2
Answers
i assume you already have defined the 3 connections in config/database.php
if so then in each model you need also to define
You can add new database connection in /config/database.php
For example (mysql connection):
Then in each model you need to define: