瀏覽代碼

Add Article model + migration

php artisan make:model -m Article
axkuhta 1 年之前
父節點
當前提交
7a36cdfaba
共有 2 個文件被更改,包括 38 次插入0 次删除
  1. 11 0
      app/Models/Article.php
  2. 27 0
      database/migrations/2023_12_02_171900_create_articles_table.php

+ 11 - 0
app/Models/Article.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Article extends Model
+{
+    use HasFactory;
+}

+ 27 - 0
database/migrations/2023_12_02_171900_create_articles_table.php

@@ -0,0 +1,27 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('articles', function (Blueprint $table) {
+            $table->id();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('articles');
+    }
+};