Comments (11)
Hi dears,
i found the same error using Passport and uuid for user_id column.
Try yourself with:
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->uuid('user_id');
$table->integer('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
and next generate a token from /oauth/token.
from laravel-binary-uuid.
So it seems that the issue doesn't come from the ->with
call, as it works with tinker.
Is it possible that return compact('user');
tries to return a JSON? This should be visible from the error trace.
If so, you can override the ->jsonSerialize
method in the model, to support the custom relations:
public function jsonSerialize()
{
return array_merge(parent::jsonSerialize(), ['user_id' => User::decodeUuid($this->user->id)]);
}
I'm afraid relations won't be automatically converted in our current implementation.
from laravel-binary-uuid.
You're right, compact
return an array, and thus it's being displayed as JSON on the browser.
I tried to override the method without success.
I ended not displaying JSON, but I guess I could $hidden
the user_id
and the workstation_id
in the Work
Model.
from laravel-binary-uuid.
@zJoul could you share your solution here before we close this issue?
from laravel-binary-uuid.
@brendt Of course, I just call my view in my controller :
return view('user.profile', compact('user'));
And if I need the id to be displayed, I just call
{{ $work->workstation->uuid_text }}
Althought I do not know about JSON representation
from laravel-binary-uuid.
I'm going to close this issue, and refer to #14 for followup, we'll revisit the default uuid
behaviour and serialisation of the binary fields for the next major version.
from laravel-binary-uuid.
Hi dears,
i found the same error using Passport and uuid for user_id column.
Try yourself with:
Schema::create('oauth_auth_codes', function (Blueprint $table) { $table->string('id', 100)->primary(); $table->uuid('user_id'); $table->integer('client_id'); $table->text('scopes')->nullable(); $table->boolean('revoked'); $table->dateTime('expires_at')->nullable(); });
and next generate a token from /oauth/token.
Did you manage to find a solution for this problem?
from laravel-binary-uuid.
@andreidmour sorry, no. I have changed package, without binary conversion.
from laravel-binary-uuid.
i am using Uuid to for user. After submiting the form i get this error "Error encoding model [Koboaccountant\Models\User] with ID [790c48b8-3eb5-5a31-ad77-333d642ef5b1] to JSON: Malformed UTF-8 characters, possibly incorrectly encoded ◀"
from laravel-binary-uuid.
What does your user class look like?
Did you add the $uuids
protected field?
Did you append uuid_text and hide uuid from json serialization?
from laravel-binary-uuid.
May be a good idea to open your own issue. This one is closed.
from laravel-binary-uuid.
Related Issues (20)
- Using pivot tables help with uuid
- [Idea] Split up HasBinaryUUID trait HOT 2
- Laravel Scout: Issue with newQueryForRestoration($id) (Add Array Support) HOT 2
- Composite Key Not Working HOT 18
- with('relation') . cause utf8 encode error HOT 5
- Malformed UTF-8 characters, possibly incorrectly encoded HOT 4
- Ordered UUID for Laravel MySQL grammar query compilation via custom builder HOT 1
- Running DB::purge() is unloading extension HOT 3
- uuid() blueprint method creates a char(36) column instead of binary(16) HOT 1
- Use ID and UUID HOT 1
- Usage with Laravel Nova HOT 5
- Question - Should I still have a fk defined $casts? HOT 2
- General error: 1215 Cannot add foreign key constraint when using relations HOT 2
- Relies on static UUID factory not being changed HOT 3
- Lack of "ID" in key name results in exception HOT 1
- Can we have an incremental id (for internal relations) too? HOT 1
- Relation model saving causes "UTF-8" Error HOT 2
- Conflict with Laravel Telescope HOT 1
- Disable blueprint override HOT 1
- Looking for maintainers / abandonment notice HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-binary-uuid.