$input */ public function create(array $input): User { Validator::make($input, [ ...$this->profileRules(), 'password' => ['required', 'string', Password::default()], ])->validate(); return DB::transaction(function () use ($input) { $user = User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => $input['password'], 'setup' => Setup::Role, ]); // Create default workspace for new user $workspace = $user->workspaces()->create([ 'name' => 'My Workspace', 'timezone' => 'UTC', ]); // Add user as owner member $workspace->members()->attach($user->id, ['role' => 'owner']); // Set as current workspace $user->update(['current_workspace_id' => $workspace->id]); return $user; }); } }