Skip to content

Commit 772d9ac

Browse files
authored
Update HasBinaryUuid.php
1 parent 1b40960 commit 772d9ac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/HasBinaryUuid.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function getRelatedBinaryKeyName($attribute)
9696
{
9797
$suffix = $this->getUuidSuffix();
9898

99-
return preg_match('/(?:uu)?id/i', $attribute) !== null ? "{$attribute}{$suffix}" : $attribute;
99+
return preg_match('/(?:uu)?id/i', $attribute) ? "{$attribute}{$suffix}" : $attribute;
100100
}
101101

102102
public function getAttribute($key)
@@ -155,16 +155,24 @@ public function getUuidAttributes()
155155

156156
public function getUuidTextAttribute(): ?string
157157
{
158-
if (! $this->exists) {
158+
$key = $this->getKeyName();
159+
160+
if (! $this->exists || is_array($key)) {
159161
return null;
160162
}
161163

162-
return static::decodeUuid($this->{$this->getKeyName()});
164+
return static::decodeUuid($this->{$key});
163165
}
164166

165167
public function setUuidTextAttribute(string $uuid)
166168
{
167-
$this->{$this->getKeyName()} = static::encodeUuid($uuid);
169+
$key = $this->getKeyName();
170+
171+
if (is_array($key)) {
172+
return;
173+
}
174+
175+
$this->{$key} = static::encodeUuid($uuid);
168176
}
169177

170178
public function getQueueableId()

0 commit comments

Comments
 (0)