ferdysetia_aan

TK4 - No.1 - /migrations/2025_08_03_000003_create_articles_table.php

Aug 3rd, 2025
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. // database/migrations/2025_08_03_000003_create_articles_table.php
  2.  
  3. use Illuminate\Database\Migrations\Migration;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6.  
  7. class CreateArticlesTable extends Migration
  8. {
  9.     public function up()
  10.     {
  11.         Schema::create('articles', function (Blueprint $table) {
  12.             $table->id();
  13.             $table->string('title');
  14.             $table->text('content');
  15.             $table->foreignId('category_id')->constrained()->onDelete('cascade');
  16.             $table->foreignId('level_id')->constrained()->onDelete('cascade');
  17.             $table->timestamps();
  18.         });
  19.     }
  20.  
  21.     public function down()
  22.     {
  23.         Schema::dropIfExists('articles');
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment