Laravel table saves wrong data

I have string column in my table which supposed to store unique tokens but instead it stores something like this:

??6?i!a\????5?&?9?

Code

controller

use Illuminate\Support\Str;

public function store(Request $request)
{
  $recipient = new RsvpPerson;
  $recipient->token = Str::random(20);
  $recipient->save();
}

Schema

Schema::create('rsvp_people', function (Blueprint $table) {
    $table->uuid('id')->primary();
    $table->string('token')->unique();
    $table->timestamps();
}

any idea?

1 answer

  • answered 2020-10-16 04:38 mafortis

    Solved

    I'm not sure why laravel helper doesn't work but using this solved the problem

    str_random(20)