Level 102
I believe you need to set the key type to string (unless it was recently changed)
protected $keyType = 'string';
Hi everyone,
I'm trying to use UUIDs instead of ids on users table, it works fine but I can't login anymore, session is not created.
First I added a HasUuid trait (and use it in App\Models\User):
trait HasUuid
{
public static function booted(): void
{
parent::boot();
static::creating(function (Model $model): void {
$model->setAttribute('uuid', Str::orderedUuid());
});
}
}
Then I added these properties to my User class:
protected $primaryKey = 'uuid';
protected $keyType = 'uuid';
public $incrementing = false;
Of course, migrations has been updated:
$table->id(); to $table->uuid()->primary();
$table->foreignId('user_id')->nullable()->index(); to $table->foreignUuid('user_id')->nullable()->index();
The issue is the same when I use other session storage. What did I miss?
Thanks :)
Please or to participate in this conversation.