When creating a user within User.php
I'm trying to define a UUID, create a directory, and then add it to the user on the DB. The folder creates successfully with the UUID but it will not get passed into the creating()
callback.
/**
* Create the user when this class is called
*
* @return void
*/
public static function boot()
{
// Setup parent
parent::boot();
// Create UUID
$uuid = Str::uuid();
// Create user directory on S3
Storage::disk('s3')->makeDirectory('users/' . $uuid);
// Assign UUID to new user
self::creating(function ($model) {
$model->id = $uuid;
});
}
$model->id = $uuid;
is undefined here and results in no value.