Add (posts)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?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('authors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('avatar');
|
||||
$table->string('bio');
|
||||
$table->boolean('enabled')->default(true);
|
||||
$table->boolean('public')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('authors');
|
||||
}
|
||||
};
|
||||
41
database/migrations/2023_07_26_155118_create_posts_table.php
Normal file
41
database/migrations/2023_07_26_155118_create_posts_table.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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('posts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title')->nullable();
|
||||
$table->string('slug')->nullable();
|
||||
$table->mediumText('excerpt')->nullable();
|
||||
$table->foreignId('author_id')->nullable();
|
||||
$table->boolean('featured')->default(false);
|
||||
$table->string('featured_image');
|
||||
$table->enum('editor', ['editorjs'])->default('editorjs');
|
||||
$table->json('body')->nullable();
|
||||
$table->enum('post_format',['standard'])->default('standard');
|
||||
$table->integer('comment_count')->default(0);
|
||||
$table->integer('likes_count')->default(0);
|
||||
$table->enum('status', ['publish','future','draft','private','trash'])->default('draft');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('author_id')->references('id')->on('authors');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('posts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('post_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('post_id');
|
||||
$table->foreignId('category_id');
|
||||
|
||||
$table->foreign('post_id')->references('id')->on('posts');
|
||||
$table->foreign('category_id')->references('id')->on('categories');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('post_categories');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user