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

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -