将来如何在特定日期和时间在Laravel中发布博客文章 [英] How can I Publish A Blog Posts In The Future On A Specific Date And TIme In Laravel
问题描述
我在使用laravel PHP框架的初学者级别.我曾在博客Web应用程序上工作,但我想进行一些升级.
I'm at the beginner level using the laravel PHP framework. I worked on a blog web application, but I want to do some upgrade.
其中一项升级是能够安排在将来选定的日期和时间发布的帖子.就像Facebook或10月CMS上的rainlab博客一样.
One of the upgrades is to be able to schedule posts to be published in the future on a selected date and time. Like that of Facebook, or that of rainlab blog in October CMS.
我不知道该怎么办,如果有人可以帮助我,我将不胜感激.
I don't know how to go about this, I would really appreciate it if someone can help me out.
推荐答案
实施延迟发布的最简单方法是在发布表中添加发布日期列(例如,published_at),并在发布日期<现在.
The easiest way to implement delayed posting is to add publish date column (e.g published_at) to posts table and retrieve posts where publish date < now.
模式:
$table->timestamp('published_at');
检索示例:
$posts = Post
::where('published_at', '<', now())
->orderByDesc('published_at')
->paginate(50);
这篇关于将来如何在特定日期和时间在Laravel中发布博客文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!