Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eLekun's avatar

Cron with laravel

hello friends, how could I make a cron in laravel that sends an email reminding the user that they have an outstanding visit, this reminder should be one day before the event. Although I have already created the mail, I would need to orient myself in the logic of the date Cheers

0 likes
7 replies
Snapey's avatar

need to know more about the models in order to suggest some code.

but basically, run a job once a day that looks for all events with a date of today+1

1 like
eLekun's avatar

@snapey Yes, I read the documentation but I don't know which method to use so that I can be alerted one day before the event and one hour before the event

Snapey's avatar
Snapey
Best Answer
Level 122

suppose you have events table and Event model, and an 'event_at' column

$events = Event::whereDate('event_at',today->addDay())->get();

then iterate over the resulting collection

1 like
eLekun's avatar

@snapey thank you very much it has worked, adding my necessary query, with what you mention, Thank you!

eLekun's avatar

@snapey What happens now is that I have to make a reminder to send mail to users one hour in advance, but I have a problem since the time of the event is a varchar, how could I evaluate it with carbon in this way:

$activities = Activity::where('activities.time_init',Carbon::now()->addHour())

Please or to participate in this conversation.