blog api created
This commit is contained in:
1 parent
4f101885a8
commit
d98bc7bbb0
27 files changed
+1022
-44
No files matched your search
@@ -0,0 +1,39 @@
|
||||
<?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');
|
||||
$table->text('body');
|
||||
$table->text('excerpt'); // توضیحات مختصر
|
||||
$table->string('slug')->unique();
|
||||
$table->unsignedBigInteger('author_id'); // نویسنده
|
||||
$table->foreign('author_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->unsignedBigInteger('category_id'); // دسته بندی
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
$table->string('featured_image')->nullable(); // تصویر شاخص
|
||||
$table->integer('views')->default(0); // تعداد بازدید
|
||||
$table->integer('likes')->default(0); // تعداد لایک
|
||||
$table->timestamp('published_at')->nullable(); // تاریخ انتشار
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('posts');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user