Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Try moving the with sentence before the where one

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.