1

I am developing a package that has its own routes controllers and migrations and everything. I want to add db connection to it. Once Package Service is used by client using its route it has to go its own database connection.

  1. Once the package installed it is required to add credentials to .env file .
  2. And db is always mysql
PACKAGE_DB_CONNECTION=my_service_db_connection
PACKAGE_DB_HOST=127.0.0.1
PACKAGE_DB_PORT=3306
PACKAGE_DB_DATABASE=forge
PACKAGE_DB_USERNAME=forge
PACKAGE_DB_PASSWORD=forge
namespace Vendor\Package\Models;

use Illuminate\Database\Eloquent\Model;

class Users extends Model
{
    protected $connection = "my_service_db_connection";
}

Please give me some information, clue, anything about the question! If you don't understand what I explained here, don't hesitate to ask to clarify the question!

0 Answers0