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

kramsuiluj's avatar

How to create a model that expires?

I have users with teacher role in my system. I want to give them the ability to make some kind of request (model instance) that will create a submission page for their students activities.

My plan on doing this is to simply set a column for the expiration date and set a column that stores a boolean that will indicate if the model instance is expired or not.

My problem is, how do you change the boolean column value let's say to true if the current date and time matches the expiration date?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

Generally we use only one column for this scenario. And we can write a local scope(s) to determine is expired or not

1 like
kramsuiluj's avatar

@tykus Oh I see, I just read about the eloquent local scopes right now, so what I need to do is just simply check if the current time matches or if greater than the expiry date.

Please or to participate in this conversation.