Add Livewire comment system

This commit is contained in:
2026-01-10 15:02:14 +01:00
parent 67f5d0db8b
commit 5f575024e2
13 changed files with 456 additions and 33 deletions

View File

@@ -0,0 +1,38 @@
<?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
{
// Remame old table from laravelista/comments
Schema::rename('comments', 'comments_old');
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('parent_id')->nullable()->constrained('comments')->cascadeOnDelete();
$table->morphs('commentable'); // What is being commented on
$table->text('body');
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('comments');
// Revert to old table from laravelista/comments
Schema::rename('comments_old', 'comments');
}
};