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

XiaTesting's avatar

how to change the field value when date field is expired

Hi all,

How to change an Event's active filed (is boolean) to false automatically when expired_at(is date) is expired. Like : expired_at: 2020-07-19 11:30:00 active: change to false if "date now" is greater than expired_at filed,

0 likes
2 replies
eth0's avatar

You could use a cron job that does that for you which will run every minute and try to mark all the expired one as false. or the next solution might be to use mysql triggers I think 🤔.

Snapey's avatar

create an artisan command that checks for expired jobs and sets the active flag

You can then schedule this with laravel scheduler.

How often you want to run it depends on how accurate it needs to be. Daily? Hourly? Every 5 minutes or every minute?

Please or to participate in this conversation.