Giter Site home page Giter Site logo

Comments (11)

masterix21 avatar masterix21 commented on May 15, 2024 1

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.

brendt avatar brendt commented on May 15, 2024

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.

zJoul avatar zJoul commented on May 15, 2024

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.

brendt avatar brendt commented on May 15, 2024

@zJoul could you share your solution here before we close this issue?

from laravel-binary-uuid.

zJoul avatar zJoul commented on May 15, 2024

@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.

brendt avatar brendt commented on May 15, 2024

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.

andreidmour avatar andreidmour commented on May 15, 2024

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.

masterix21 avatar masterix21 commented on May 15, 2024

@andreidmour sorry, no. I have changed package, without binary conversion.

from laravel-binary-uuid.

ekpono avatar ekpono commented on May 15, 2024

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.

vpratfr avatar vpratfr commented on May 15, 2024

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.

vpratfr avatar vpratfr commented on May 15, 2024

May be a good idea to open your own issue. This one is closed.

from laravel-binary-uuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.