Skip to content

Commit

Permalink
fix: patch up config
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Aug 23, 2024
1 parent 068de19 commit 5722c28
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Db/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(
string $dbtype = 'mysql'
) {
if (class_exists('Leaf\App')) {
app()->config('db.config', $this->config);
\Leaf\Config::set('db.config', $this->config);
}

if ($host !== '') {
Expand Down Expand Up @@ -263,13 +263,17 @@ public function table(string $table): self
public function config($name, $value = null)
{
if (class_exists('Leaf\App') && function_exists('app')) {
if (!$value && is_string($name)) {
return $this->config[$name] ?? null;
}

$this->config = array_merge($this->config, $name);

if (!is_array($name)) {
$this->config[$name] = $value;
}

app()->config('db.config', array_merge(app()->config('db.config'), $this->config));
\Leaf\Config::set('db.config', $this->config);
} else {
if (is_array($name)) {
$this->config = array_merge($this->config, $name);
Expand Down

0 comments on commit 5722c28

Please sign in to comment.