@JacobBarkerAug 11.2022 — #I encountered this in a recent project: You would have to define a second database connection in config/database.php 'otherdb' => [ 'driver' => env('DB_CONNECTION_SECOND'), 'host' => env('DB_HOST_SECOND'), 'port' => env('DB_PORT_SECOND'), 'database' => env('DB_DATABASE_SECOND'), 'username' => env('DB_USERNAME_SECOND'), 'password' => env('DB_PASSWORD_SECOND'), ],
And then define those values in your .env file: DB_CONNECTION_SECOND=mysql DB_HOST_SECOND=127.0.0.1 DB_PORT_SECOND=3306 DB_DATABASE_SECOND=database2 DB_USERNAME_SECOND=root DB_PASSWORD_SECOND=secret
You can change the DB_CONNECTION_SECOND (and effectively the driver on the otherdb connection) to a different driver (for example sqlite)
You can then use the second connection in the query builder: $users = DB::connection('otherdb')->select(...); or set the model's connection property: protected $connection = 'otherdb'; to use it with eloquent. In order to use this with migrations as well, set the connection on the Schema: Schema::connection('otherdb')->create('some_table', function($table) { $table->increments('id'): });