0

I have created a plugin in OctoberCMS to store users information and products expiry date.

I want to make Event fire when expiry date is close to current date and send email to the user, how can I monitor the date (should I use contrib shell command)? how do I approach this?

Regards,

Ya Basha
  • 1,902
  • 6
  • 30
  • 54

1 Answers1

1

Probably you need cron-jobs https://en.wikipedia.org/wiki/Cron

Server will execute scheduler based on time you define in your cron-job, In Your case it will be good to schedule it every day.

now every day it will fire you scheduler > then it will call your Task (https://octobercms.com/docs/plugin/scheduling#introduction) with your logic.

Logic

You will fetch records with condition like :

current_date + 1/2/3 day convert that date in to timestamp and store to variable future_date

And add condition on field expiry_date

expiry_date > today_time_stamp AND expiry_date < future_date

It will give you records which are about to expire in next 1/2/3 days

now notify [send email] or fire event for these records

You can add master cron job to your server just follow this guide https://octobercms.com/docs/setup/installation#crontab-setup

Then you can just write you logic how you want thing to be done https://octobercms.com/docs/plugin/scheduling#introduction

if any doubt please comment

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40