© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
14 replies
Roland Barkóczi

user model with PK type string

I encountered with a rather strange bug:
- I installed a fresh laravel 11 app, then I added the filement plugin, migrated the database, created a user, and I was able to log in to the panel without any issue.

Because of business requirements, I want to change the User model primary key to uuid ($table->uuid('id')->primary(); in my migration file), I also added

public $keyType = 'string';
public $incrementing = false;
...
public static function boot()
{
parent::boot();

static::creating(function ($model) {
$model->id = (string) uniqid("usr_");
});
}

to my User model.

Refreshed the database, recreated a new user, but after these changes I cannot log in anymore into the app.

I debugged the app, the user record queried correctly at login, but it redirects back to the login screen, because in the vendor/filament/filament/src/Http/Middleware/Authenticate.php file, line 22:
if (!$guard->check()) {
$this->unauthenticated($request, $guards);
return;
}
the $guard->check() returns null.

Could you give me any clue, why it isn't working with PK type string?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Custom User model
FilamentFFilament / ❓┊help
3y ago
Filament Shield type error in User.php model file
FilamentFFilament / ❓┊help
2y ago
Admin Model instead of User model
FilamentFFilament / ❓┊help
9mo ago
email verification with UUID on user model
FilamentFFilament / ❓┊help
2y ago