mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
use getAttribute() in HasDatabase to support encrypted columns
This commit is contained in:
parent
711352db38
commit
29d1469651
1 changed files with 4 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ trait HasDatabase
|
||||||
/** @var TenantWithDatabase&Model $this */
|
/** @var TenantWithDatabase&Model $this */
|
||||||
$databaseConfig = [];
|
$databaseConfig = [];
|
||||||
|
|
||||||
foreach ($this->getAttributes() as $key => $value) {
|
foreach (array_keys($this->getAttributes()) as $key) {
|
||||||
if (str($key)->startsWith($this->internalPrefix() . 'db_')) {
|
if (str($key)->startsWith($this->internalPrefix() . 'db_')) {
|
||||||
if ($key === $this->internalPrefix() . 'db_name') {
|
if ($key === $this->internalPrefix() . 'db_name') {
|
||||||
// Remove DB name because we set that separately
|
// Remove DB name because we set that separately
|
||||||
|
|
@ -32,7 +32,9 @@ trait HasDatabase
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$databaseConfig[str($key)->after($this->internalPrefix() . 'db_')->toString()] = $value;
|
// We use getAttribute() instead of getting the value directly from the attributes array
|
||||||
|
// to support encrypted columns and any other types of casts.
|
||||||
|
$databaseConfig[str($key)->after($this->internalPrefix() . 'db_')->toString()] = $this->getAttribute($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue