I'd do the following:
- add another column to your post model, published_at (timestamp)
- Create a scope (or global scope) for your post model, showing published posts only.
- Order your posts by published_at
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey,
Let's say that I have a blog and I want to schedule posts to be published in the future on a selected date and time. Jeffrey uses this on Laracasts to post new lessons when he's on vacation.
But the thing I am not sure is how would I accomplish this and where would I put the publishing logic? Should I use events? Cron jobs? Queues? How would I check constantly if the current date and time is equal to the scheduled date and time?
I'd run a scheduled task / cron job for sending notifications, but not tie this directly to the publishing.
You can have it run every 10 minutes or so, to send out new updates, or whatever you require (most places do it nightly, and send out an email with all new ones)
Please or to participate in this conversation.