Skip to content

Commit 4f5e507

Browse files
committed
Merge pull request #74 from diepxuan/feat/overwrite-legacy-code
fix: correct Simba database connection configuration
1 parent 29aa8fa commit 4f5e507

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/SModel/SModel.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SModel extends Model
2424
*
2525
* @var string
2626
*/
27-
protected $connection = 'simba';
27+
protected $connection;
2828

2929
/**
3030
* Indicates if the model should be timestamped.
@@ -82,6 +82,19 @@ class SModel extends Model
8282
*/
8383
protected $casts = [];
8484

85+
/**
86+
* Create a new Eloquent model instance.
87+
* Overwrites legacy constructor with connection setup.
88+
*
89+
* @param array $attributes
90+
* @return void
91+
*/
92+
public function __construct(array $attributes = [])
93+
{
94+
parent::__construct($attributes);
95+
$this->connection = $this->getSimbaConnectionName();
96+
}
97+
8598
/**
8699
* Get the table name.
87100
* Overwrites legacy table name handling.

src/Traits/HasSimbaConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait HasSimbaConnection
2323
*/
2424
public function getSimbaConnectionName(): string
2525
{
26-
return Config::get('database.simba_connection', 'simba');
26+
return Config::get('simba.connection', 'sqlsrv');
2727
}
2828

2929
/**

0 commit comments

Comments
 (0)