Laravel

How to connect multiple database in laravel 5.5

How to connect multiple database in laravel 5.5

In some situations we need to use multiple databases for same application. Lets see how to use multiple database in laravel 5.5

Step 1

Install your laravel application and connect with primary database

Step 2

Create second database in your phpmyadmin

Step 3

Provide your database connection details in your config/database.php

For eg :



Step 4

Use your database connection in Schema to create table for your new tables for new database

Step 5

Run your migration to create table

Step 6

Product your model with connection

Thats it, Now you can acces role table from another database.
Hope it will help someone.