Przeglądaj źródła

Rename published_at/unpublished_at -> publish_at/unpublish_at to suggest future action

Also make them nullable and add a sample article
axkuhta 1 rok temu
rodzic
commit
fd4a99e943

+ 6 - 0
app/Console/Commands/LoadSampleData.php

@@ -3,6 +3,7 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
+use App\Models\Article;
 use App\Models\Author;
 use App\Models\Book;
 
@@ -27,6 +28,11 @@ class LoadSampleData extends Command
      */
     public function handle()
     {
+		$article = new Article;
+		$article->title = "Test article";
+		$article->content = "Test article contents";
+		$article->save();
+
         $author = new Author;
         $author->name = "Howard Johnson";
         $author->save();

+ 2 - 2
database/migrations/2023_12_02_171900_create_articles_table.php

@@ -17,8 +17,8 @@ return new class extends Migration
             $table->softDeletes();
             $table->string("title");
             $table->text("content");
-            $table->timestamp("published_at");
-            $table->timestamp("unpublished_at");
+            $table->timestamp("publish_at")->nullable();
+            $table->timestamp("unpublish_at")->nullable();
             $table->tinyInteger("status")->unsigned()->default(0);
         });
     }