Advaith
Advaith

Reputation: 2580

Automatically notify a user when event date approach

I have a table called events where all the user created events are registered. Its structure is like this: id, user_id, event_at and event

So what I want is to create a new notification when the event_at time approach in the backend. It will be like even if no users are in any route this should be run and a new notification should be created in the database. I have setup the notification table and class. So all I want to know is how to run this command on the time approch.

$event->user->notify(new NotifyAtEvent($event));

where the $event is the particular event.

Upvotes: 0

Views: 686

Answers (2)

Rajeev Radhakrishnan
Rajeev Radhakrishnan

Reputation: 1004

Laravel's command scheduler allows you to fluently and expressively define your command schedule within Laravel itself. When using the scheduler, only a single Cron entry is needed on your server. Your task schedule is defined in the app/Console/Kernel.php file's schedule method.

You can read docs regarding about by clicking here

or Watch series of Jeffrey Way.

Upvotes: 1

Munteanu Petrisor
Munteanu Petrisor

Reputation: 491

You will need to use Laravel Task Scheduling and cronjobs. For example , you have a cronjob that runs the script daily and on that function in laravel you check if you have any event that you have to send emails.

Here is the documentation reference, it is straightforward.

https://laravel.com/docs/5.6/scheduling

Upvotes: 1

Related Questions