return User::create([
'id' => (string) Str::orderedUuid(),
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
Ref: https://laravel.com/docs/8.x/helpers#method-str-ordered-uuid
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
App\Models\User
protected $casts = [
'email_verified_at' => 'datetime',
'id' => 'string'
];
App\Http\Controllers\Auth\RegisterController
return User::create([
'id' => uniqid() . substr(md5(rand()), 0, 4),
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
That's hardly related to UUID generation.
Has the id field been added to the $fillable property of the User model?
(or excluded from the $guarded property)
See the last paragraph, just before "Updates": https://laravel.com/docs/8.x/eloquent#inserts
Please or to participate in this conversation.