You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
Currently it is not possible to json serialize any model that uses this package because the uuid field is in binary format.
json_encode(\App\Announcement::first());
dd(json_last_error()); // Results in 5 which equals JSON_ERROR_UTF8
I am currently solving this issue by using protected $hidden = ['uuid']; and protected $appends = ['id'] where ID is the method from here #12
It might be worth considering to replace the uuid field data with the uuid_text attribute value for the array format to allow working with it without any extra hacks like I do right now.
The text was updated successfully, but these errors were encountered:
This is what I currently use as a workaround for all my models.
<?phpnamespaceApp\Traits;
useIlluminate\Database\Eloquent\Model;
traitHasUuidPrimaryKey
{
/** * Get the textual id of the entity. * * @return string */publicfunctiongetIdAttribute()
{
return$this->uuid_text;
}
/** * Get the hidden attributes for the model. * * @return array */publicfunctiongetHidden()
{
return ['uuid'] + $this->hidden;
}
/** * Get the primary key for the model. * * @return string */publicfunctiongetKeyName()
{
return'uuid';
}
/** * Get the value indicating whether the IDs are incrementing. * * @return bool */publicfunctiongetIncrementing()
{
returnfalse;
}
}
Currently it is not possible to json serialize any model that uses this package because the uuid field is in binary format.
I am currently solving this issue by using
protected $hidden = ['uuid'];
andprotected $appends = ['id']
where ID is the method from here #12It might be worth considering to replace the uuid field data with the uuid_text attribute value for the array format to allow working with it without any extra hacks like I do right now.
The text was updated successfully, but these errors were encountered: