48 lines
963 B
PHP
48 lines
963 B
PHP
<?php
|
|
|
|
namespace app\config;
|
|
|
|
|
|
use Illuminate\Database\Connection;
|
|
use support\Db;
|
|
|
|
class DatabaseConfig
|
|
{
|
|
public string $host = 'localhost' {
|
|
get {
|
|
return $this->host;
|
|
}
|
|
}
|
|
public string $username = 'root' {
|
|
get {
|
|
return $this->username;
|
|
}
|
|
}
|
|
public string $password = '' {
|
|
get {
|
|
return $this->password;
|
|
}
|
|
}
|
|
public string $database = 'opm_ectms' {
|
|
get {
|
|
return $this->database;
|
|
}
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
$this->host = getenv('DB_HOST');
|
|
$this->username = getenv('DB_USER');
|
|
$this->password = getenv('DB_PASSWORD');
|
|
$this->database = getenv('DB_NAME');
|
|
}
|
|
|
|
/**
|
|
* @param $connection string|null
|
|
* @return Connection
|
|
*/
|
|
public function getConnection(?string $connection = null): Connection
|
|
{
|
|
return Db::connection($connection);
|
|
}
|
|
} |