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

mrkarma4ya's avatar

Sending reminder emails to users based on their last activity date

Hello,

I want to send reminder emails to my users if they have not completed their profile.

I have a last_active_at date column and profile_complete boolean column in users table.

I want to send reminder notification to users whose profile_complete is false after 24 hrs, then 1 week and then 1 month from their last_active_at date. After 1 month, the reminder emails will not be sent to them until their activity date is updated.

I'm thinking of creating a job and scheduling it to run everyday, but I'm having a hard time implementing the logic.

0 likes
3 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

What part are you struggling with?

Should just be a question of quering for users when for instance last_active_at, which is 1 day old etc.

Laravel has a ->whereDate() query helper to check for a specific day

$yesterday = now()->subDay()->toDateString();
1 like
mrkarma4ya's avatar

@Sinnbeck Hmm, I was thinking of doing with 'last_active_at', '<', $yesterday, so it was causing the reminder to be sent everyday instead of just one day. I didn't even think of comparing equal date, thanks for this. Doing it like this now:

// Daily Reminders
$yesterday = now()->subDay()->toDateString();
$users = User::whereDate('last_active_at', $yesterday);
foreach ($users as $key => $user) {
    // Notify user
}
Sinnbeck's avatar

@mrkarma4ya remeber ->get()

$users = User::whereDate('last_active_at', $yesterday)->get();
1 like

Please or to participate in this conversation.