1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:14:04 +00:00

use getAttribute() in HasDatabase to support encrypted columns

This commit is contained in:
Samuel Štancl 2024-04-02 20:25:17 +02:00
parent 711352db38
commit 29d1469651

View file

@ -20,7 +20,7 @@ trait HasDatabase
/** @var TenantWithDatabase&Model $this */
$databaseConfig = [];
foreach ($this->getAttributes() as $key => $value) {
foreach (array_keys($this->getAttributes()) as $key) {
if (str($key)->startsWith($this->internalPrefix() . 'db_')) {
if ($key === $this->internalPrefix() . 'db_name') {
// Remove DB name because we set that separately
@ -32,7 +32,9 @@ trait HasDatabase
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);
}
}