Laravel scheduler start and run in custom times and not just from 0 time

57 Views Asked by At

Users in the application save a reminder for example at 10:45 and the system should send an email or message to him every 30 minutes. the problem is time starts from 11 and sends the message to the user at 11, 11:30, 12, 12:30, ... It doesn't start from 10:45. It should start from the time that user creates its reminder.

in following example $reminder->expression is for example */30 * * * *

Kernel.php

$user->reminders()->active()->each(function ($reminder) use ($user, $schedule) {
    return $schedule->call(function () use ($reminder) {
         $sendReminder = app(SendReminder::class , ['reminder' => $reminder]);
         $sendReminder->sendReminder(); 
     })->cron($reminder->expression);
});
0

There are 0 best solutions below