How to automatically set a random string ID in Laravel when a user registers -
i set unique random string (str_random) user id automatically when user registered.
where put code?
'id' => str_random(32);
i thought should go in user.php (model).
you in model:
public static function boot() { parent::boot(); static::creating(function($table) { $table->id = str_random(32); }); }
Comments
Post a Comment