-
Notifications
You must be signed in to change notification settings - Fork 58
Prevent decoding the uuid when the model does not exist #40
Conversation
return array_merge(parent::toArray(), [$this->getKeyName() => $this->uuid_text]); | ||
} | ||
|
||
public function getUuidTextAttribute(): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be type hinted as a nullable string:
public function getUuidTextAttribute(): ?string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nullable types are not available in PHP 7.0. Do you want me to change php requirement in the composer.json
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed that, yes feel free to bump the PHP version!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍 I've changed Travis configuration as well. Yolo, right?
src/HasBinaryUuid.php
Outdated
{ | ||
if (! $this->exists) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
should be returned here.
src/HasBinaryUuid.php
Outdated
@@ -6,6 +6,9 @@ | |||
use Illuminate\Database\Eloquent\Model; | |||
use Illuminate\Database\Eloquent\Builder; | |||
|
|||
/** | |||
* @property string|null $uuid_text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docblock should be removed as $uuid_text
isn't always the name of the textual property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean 👍
🎊Thanks! |
Released and tagged: https://github.com/spatie/laravel-binary-uuid/releases/tag/1.1.6 |
This resolves issue #39.