From the manual (highlighed the important part):
Counting Related Models
If you want to count the number of results from a relationship
without actually loading themyou may use the withCount method, which will place a {relation}_count column on your resulting models.
https://laravel.com/docs/5.6/eloquent-relationships#counting-related-models
So use 2 queries. The one that I helped with yesterday that we got working for pagination (not using withCount), and a separate query to get the count of all products in the category.