|
@@ -0,0 +1,50 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace App\Console\Commands;
|
|
|
|
+use App\Models\Post;
|
|
|
|
+
|
|
|
|
+use Illuminate\Console\Command;
|
|
|
|
+
|
|
|
|
+class earlyPublication extends Command
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * The name and signature of the console command.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $signature = 'publish:content';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The console command description.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $description = 'Early publication';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create a new command instance.
|
|
|
|
+ *
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Execute the console command.
|
|
|
|
+ *
|
|
|
|
+ * @return int
|
|
|
|
+ */
|
|
|
|
+ public function handle()
|
|
|
|
+ {
|
|
|
|
+ $posts = Post::where('created_at', '<=', now())->get();
|
|
|
|
+
|
|
|
|
+ foreach ($posts as $post) {
|
|
|
|
+ $post->created_at = now();
|
|
|
|
+ $post->save();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->info('Dates have been changed.');
|
|
|
|
+ }
|
|
|
|
+}
|