add Comment persistence: model, migration, eloquent + fake repo

This commit is contained in:
Yisroel Baum 2026-05-06 22:14:11 +03:00
parent 0d589340d9
commit 93da08756c
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 219 additions and 0 deletions

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('post_id')
->constrained('posts')
->cascadeOnDelete();
$table->foreignId('user_id')
->constrained('users')
->cascadeOnDelete();
$table->text('body');
$table->dateTime('created_at')->index();
});
}
public function down(): void
{
Schema::dropIfExists('comments');
}
};