michaeldyrynda / laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models
MIT License
442 stars 46 forks source link

Strings with invalid UTF-8 byte sequences cannot be escaped. #135

Closed masterix21 closed 1 week ago

masterix21 commented 1 week ago
Package Version
php 8.3.8
laravel 11.11.1
laravel-model-uuid 8.0.0
ramsey/uuid 4.7.6
mysql-server 8.3.0

Hi.

Using your package, I'm facing the error Strings with invalid UTF-8 byte sequences cannot be escaped..

I've added the column uuid to my users table like so:

Schema::table('users', function (Blueprint $table) {
    $table->efficientUuid('uuid')->after('id')->unique();
});

Then, I've changed the User model like so:

class User extends Authenticatable implements MustVerifyEmail, Subscriber
{
    // ... other traits ...
    use GeneratesUuid;

    // ...

    protected function casts(): array
    {
        return [
            'uuid' => EfficientUuid::class,
            'email_verified_at' => 'datetime',
        ];
    }
}

After all, I've created in the web.php an endpoint like this:

Route::get('/test', function () {
    return response()->json(
        User::create([
            'first_name' => fake()->firstName(),
            'last_name' => fake()->lastName(),
            'email' => fake()->email,
            'mobile' => fake()->phoneNumber(),
            'password' => Hash::make('password'),
        ])
    );
});

Finally, the result with /test is:

image

Do you happen to have an idea to solve this?

Thanks!

masterix21 commented 1 week ago

Found! The issue is caused by Telescope.