mirror of
https://github.com/archtechx/virtualcolumn.git
synced 2025-12-12 14:14:05 +00:00
Early return in the listener if data column isn't required
This commit is contained in:
parent
2d61396e54
commit
09bdf523e0
1 changed files with 5 additions and 7 deletions
|
|
@ -43,13 +43,7 @@ trait VirtualColumn
|
|||
['encrypted', 'encrypted:array', 'encrypted:collection', 'encrypted:json', 'encrypted:object'], // Default encrypted castables
|
||||
);
|
||||
|
||||
try {
|
||||
$data = $this->getAttribute(static::getDataColumn()) ?? [];
|
||||
} catch (MissingAttributeException) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
foreach ($this->getAttribute(static::getDataColumn()) ?? [] as $key => $value) {
|
||||
$attributeHasEncryptedCastable = in_array(data_get($this->getCasts(), $key), $encryptedCastables);
|
||||
|
||||
if ($attributeHasEncryptedCastable && $this->valueEncrypted($value)) {
|
||||
|
|
@ -114,6 +108,10 @@ trait VirtualColumn
|
|||
return [
|
||||
'retrieved' => [
|
||||
function () {
|
||||
if (($this->attributes[static::getDataColumn()] ?? null) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always decode after model retrieval
|
||||
$this->dataEncoded = true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue