48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?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('pages', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('title');
|
|
$table->string('slug')->unique();
|
|
$table->longText('content')->nullable();
|
|
$table->text('excerpt')->nullable();
|
|
$table->string('meta_title')->nullable();
|
|
$table->text('meta_description')->nullable();
|
|
$table->enum('status', ['draft', 'published', 'archived'])->default('draft');
|
|
$table->string('featured_image')->nullable();
|
|
$table->timestamp('published_at')->nullable();
|
|
$table->foreignId('author_id')->constrained('users')->onDelete('cascade');
|
|
$table->foreignId('parent_id')->nullable()->constrained('pages')->onDelete('cascade');
|
|
$table->integer('sort_order')->default(0);
|
|
$table->string('template')->default('default');
|
|
$table->boolean('is_homepage')->default(false);
|
|
$table->boolean('show_in_menu')->default(true);
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->index(['status', 'published_at']);
|
|
$table->index(['parent_id', 'sort_order']);
|
|
$table->index('slug');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('pages');
|
|
}
|
|
};
|