user model with PK type string
I encountered with a rather strange bug:
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?
- 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.
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?