fix: notif

This commit is contained in:
2025-12-13 16:09:17 +03:30
parent 6be6c367ca
commit ba10906673
+21 -8
View File
@@ -26,22 +26,35 @@ class SendDueReminders extends Command
public function handle(): int public function handle(): int
{ {
$now = now(); $now = now();
$currentTime = $now->toTimeString(); // HH:MM:SS
$this->info("Current time: {$now}");
$this->info("Current time string: {$currentTime}");
$reminders = Reminder::with(['user', 'packageName']) $reminders = Reminder::with(['user', 'packageName'])
->where('time', '<=', $now->toTimeString()) ->where(function ($query) use ($now, $currentTime) {
->where(function ($query) use ($now) { // Compare only the TIME portion
// Non-repeatable reminders: send once $query->whereRaw('TIME(time) <= ?', [$currentTime])
$query->where('repeatable', false)
->whereNull('last_repeat')
// OR repeatable reminders that haven't been sent today
->orWhere('repeatable', true)
->where(function ($sub) use ($now) { ->where(function ($sub) use ($now) {
$sub->whereNull('last_repeat') // Non-repeatable: send once
$sub->where('repeatable', false)
->whereNull('last_repeat')
// OR repeatable: not sent today
->orWhere('repeatable', true)
->where(function ($inner) use ($now) {
$inner->whereNull('last_repeat')
->orWhereDate('last_repeat', '<', $now->toDateString()); ->orWhereDate('last_repeat', '<', $now->toDateString());
}); });
});
}) })
->get(); ->get();
// Debug: Show what reminders were found
$this->info("Found {$reminders->count()} reminders");
foreach ($reminders as $reminder) {
$this->info("Reminder ID {$reminder->id}: time={$reminder->time}, last_repeat={$reminder->last_repeat}");
}
if ($reminders->isEmpty()) { if ($reminders->isEmpty()) {
$this->info('No reminders due at this time.'); $this->info('No reminders due at this time.');
return Command::SUCCESS; return Command::SUCCESS;