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!
We'd like to thank these amazing companies for supporting us