|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
+use App\Models\Article;
|
|
|
|
|
|
class PublishScheduledArticles extends Command
|
|
|
{
|
|
@@ -25,6 +26,21 @@ class PublishScheduledArticles extends Command
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
- //
|
|
|
+ $pending_up = Article::pending()->get();
|
|
|
+ $pending_down = Article::published()->whereNotNull("unpublish_at")->get();
|
|
|
+
|
|
|
+ foreach ($pending_up as $article) {
|
|
|
+ if ($article->publish_at->isPast()) {
|
|
|
+ $this->info("Publishing [$article->title] at " . now());
|
|
|
+ $article->publish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($pending_down as $article) {
|
|
|
+ if ($article->unpublish_at->isPast()) {
|
|
|
+ $this->info("Taking down [$article->title] at " . now());
|
|
|
+ $article->unpublish();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|