'Laravel Package that has own db connection

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!



Solution 1:[1]

There is no way to import users currently in pgAdmin. However, you can mount your own storage directory - https://www.pgadmin.org/docs/pgadmin4/6.3/container_deployment.html#mapped-files-and-directories which will persist even if docker is restarted. You just need to create the users once.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aditya Toshniwal