Try moving the with sentence before the where one
The only thing that could be wrong there is the order in this part:
$count = $query->count();
$formatted_date = $date->format('Y-m-d H:i:s');
$query->where('measurements.created_at','>=',$formatted_date);
for the where statement is applied after the count is fired, so your $count holds value ignoring that where. Just swap the two and it may get you the result you need.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community