在MySQL的“我的用户”表中创建一个“创建新用户”,同时尝试在配置文件表中的同一用户中创建标题。
这是来自freeCodeCamp的laravel课程。
protected static function boot()
{
parent::boot();
static::created(function ($user) {
$user->profile()->create([
'title' => $user->username,
]);
});
}
我希望用户一旦注册就可以为用户创建一个可空文件。