Error with assignRole when I pass a string. #2329
-
Hi. Today have been migrating from id autoincrement to uuid, but I have this error when I run seeds. The code for my seed is
and yes, I already have the superadmin role. My User model has the HasRoles trait, and my migration for permissions is
I find it curious that the SQL query
role_id is only 98768 and not uuid completed Do you have any idea about what is wrong with my code? PD: if I pass an instance of Role, it works perfectly and role_id is a uuid complets.
PD2: the Role model has extended Roles
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
What version of the package are you using? /ping @erikn69 |
Beta Was this translation helpful? Give feedback.
-
is Trait <?php
namespace App;
use Facades\Str;
trait UuidTrait
{
public static function bootUuidTrait()
{
static::creating(function ($model) {
$model->keyType = 'string';
$model->incrementing = false;
$model->{$model->getKeyName()} = $model->{$model->getKeyName()} ?: (string) Str::orderedUuid();
});
}
public function getIncrementing()
{
return false;
}
public function getKeyType()
{
return 'string';
}
} |
Beta Was this translation helpful? Give feedback.
-
For some reason, it works. What did I do? I use docker-compose.
|
Beta Was this translation helpful? Give feedback.
is Trait
HasUuid
like this uuid?