parfum/database/migrations/2025_10_03_025736_create_articles_table.php
Yoga Pangestu 8b8ce3077b feat(article): implementasi crud
-membuat permission di seeder
-membuat enum untuk status
2025-10-03 13:48:40 +07:00

39 lines
1.2 KiB
PHP

<?php
use App\Enums\ArticleStatus;
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->foreignId('author_id')->constrained('users')->cascadeOnDelete();
$table->string('title', 200);
$table->string('slug')->unique();
$table->text('excerpt');
$table->text('content');
$table->enum('status', [ArticleStatus::values()])->default(ArticleStatus::PUBLISH)->comment(ArticleStatus::comment());
$table->timestamp('published_at')->nullable();
$table->unsignedInteger('views')->default(0);
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('articles');
}
};