workspace->posts()->create([ 'user_id' => $user->id, 'content' => $original->content, 'media' => $original->media, 'status' => PostStatus::Draft, 'scheduled_at' => null, 'published_at' => null, ]); foreach ($original->postPlatforms as $platform) { $copy->postPlatforms()->create([ 'social_account_id' => $platform->social_account_id, 'platform' => $platform->platform, 'platform_name' => $platform->platform_name, 'platform_username' => $platform->platform_username, 'platform_avatar' => $platform->getRawOriginal('platform_avatar'), 'content_type' => $platform->content_type, 'enabled' => $platform->enabled, 'meta' => $platform->meta, // Always reset platform-level status — never carry // published/failed/publishing into the new draft. 'status' => PostPlatformStatus::Pending, 'platform_post_id' => null, 'platform_url' => null, 'error_message' => null, 'error_context' => null, 'published_at' => null, ]); } $copy->labels()->attach($original->labels->pluck('id')); return $copy; }); } }