在创建用户时,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;在这里未定义并且没有任何值。
1 回答

qq_遁去的一_1
TA贡献1725条经验 获得超8个赞
像这样注入$uuid
闭包:
self::creating(function ($model) use ($uuid) { $model->id = $uuid; });
- 1 回答
- 0 关注
- 82 浏览
添加回答
举报
0/150
提交
取消