fix: notif
This commit is contained in:
@@ -25,23 +25,36 @@ 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
|
||||||
->orWhereDate('last_repeat', '<', $now->toDateString());
|
$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();
|
->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;
|
||||||
|
|||||||
Reference in New Issue
Block a user