fix: notif
This commit is contained in:
@@ -26,22 +26,35 @@ class SendDueReminders extends Command
|
||||
public function handle(): int
|
||||
{
|
||||
$now = now();
|
||||
$currentTime = $now->toTimeString(); // HH:MM:SS
|
||||
|
||||
$this->info("Current time: {$now}");
|
||||
$this->info("Current time string: {$currentTime}");
|
||||
|
||||
$reminders = Reminder::with(['user', 'packageName'])
|
||||
->where('time', '<=', $now->toTimeString())
|
||||
->where(function ($query) use ($now) {
|
||||
// Non-repeatable reminders: send once
|
||||
$query->where('repeatable', false)
|
||||
->whereNull('last_repeat')
|
||||
// OR repeatable reminders that haven't been sent today
|
||||
->orWhere('repeatable', true)
|
||||
->where(function ($query) use ($now, $currentTime) {
|
||||
// Compare only the TIME portion
|
||||
$query->whereRaw('TIME(time) <= ?', [$currentTime])
|
||||
->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());
|
||||
});
|
||||
});
|
||||
})
|
||||
->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()) {
|
||||
$this->info('No reminders due at this time.');
|
||||
return Command::SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user