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

Cheers02's avatar

How to send notification via email to all user when date today = date in database

this is my DB user table

users table
id  name    email
1   James   [email protected]
2   Harry   [email protected]
3   Diana   [email protected]
4   Mey [email protected]

job table
id  idUser  date        jobName
1   1       2017-11-17  JOB A
2   2       2017-11-17  JOB B
3   3       2017-11-18  JOB C
4   4       2017-11-19  JOB D

i want to send notification via email when date in my database = date today.. example date today is 2017-11-17, so system automatically send notification via email to idUser 1 and 2, like this

FOR USER ID =1
YOU HAVE JOB TODAY JAMES, 
JOB NAME = JOB A
FOR USER ID =2
YOU HAVE JOB TODAY HARRY, 
JOB NAME = JOB B
0 likes
4 replies
peacengara's avatar

*** The Easiest way would be to create a Laravel Scheduler ok. ***

So you can call your function from the schedule command

Open app/console/Kernel.php and under scheduler an example

   $schedule->call(function () {
              $this->send_job_notifier()
      })->daily();

*** Create another function still in the kernel ***

   protected function send_job_notifier() {

      // get carbon date function here and calculate date differences and match against today

     }

I Suggest you use Carbon for your dates, it's included with your laravel instance for docs: Carbon Package

Please or to participate in this conversation.