This error can occur in your php/laravel application for a variety of reasons. I encountered it when trying to run a laravel 5.7 app on php 7.2. I later discovered that there were breaking changes in php 7.2 .

The root cause being that PHP 7.2 emits a warning when you call count() on a query with no results.

There are a number of solutions for this. You can check if your query result is empty before calling count. Here is an example

//instead of 
$count = Posts::where('published', '=', true)->get();
    //do something with the posts

//do this instead
$published_posts = Posts::where('published', '=', true)->get();
    //do something with the posts

For more information please visit this github issue