Your question is vague. Are you asking about conditionally rendering content or are you talking about publishing content on some kind of schedule? Or maybe both? Or something else? You're going to have to elaborate.
Automatic publishing and hiding post using time and date
Hi! I am developing a news website, is there a way to automatically publish and hide/archive a content you made on a schedule? Like I will set a date for it to be publish and set another date for it to be hidden/archived. is there a built in function for it in the Laravel or package?
@Jeyziii Not sure why you tagged me, but I can try to help you out.
Usually, you would set a published_at field in the database. If this field is empty, the post is not published. If you want to publish it, you add a date to that field. If the date is in the past, the post is "published". If it's in the future you won't see it.
You will get a query like this
Post::whereDate('published_at', '<=', Carbon::now())->get();
Please or to participate in this conversation.