在创建用户时,User.php我试图定义一个 UUID,创建一个目录,然后将其添加到数据库上的用户。该文件夹使用 UUID 成功创建,但不会传递到creating()回调中。
/**
* 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;在这里未定义并且没有任何值。
qq_遁去的一_1