authorize('create-workspace'); if (!is_string($input)) { throw ValidationException::withMessages(['name' => WorkspaceName::MESSAGE]); } try { $name = WorkspaceName::normalize($input); } catch (InvalidArgumentException $error) { throw ValidationException::withMessages(['name' => $error->getMessage()]); } $id = DB::transaction(fn () => DB::table('workspaces')->insertGetId([ 'name' => $name, 'created_by' => $actor->getAuthIdentifier(), ])); return ['id' => $id, 'name' => $name]; } }