Apologies for the hyper-specific title, here's what I'm trying to do and am stuck on the logic.
Users can set a time of day that they want their goal to reset i.e. 4:00 AM (UTC), and a command is run via scheduling on the server every minute.
How can I query the database so that it only grabs Goals that have not already been reset today and are after the time specified?
The table has a progress
field and reset_time
field.
So far I have
$goals = \App\Goal::whereTime('reset_time', '>=', \Carbon\Carbon::now()->toTimeString())
->get();
foreach ($goals as $goal) {
$goal->progress = 0;
$goal->save();
}
but in the 4:00 AM example anything from 4:01-23:59 would be queried, resulting in progress being reset every minute.
How should I tackle this?